개정판 1ab9a205
dev issue #366 : SpecBreak, EndBreak Modeling 방식 수정 (ZeroLength 이용)
Change-Id: Ie64b0e1eed8440f2254a0a54d1567608623f8a50
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
119 | 119 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStep, AllCount); |
120 | 120 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
121 | 121 |
|
122 |
SetSystemEditingCommand(false); |
|
123 |
|
|
124 | 122 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Priority Symbol Modeling"); |
125 | 123 |
List<Symbol> prioritySymbols = GetPrioritySymbol(); |
126 | 124 |
foreach (var item in prioritySymbols) |
... | ... | |
186 | 184 |
foreach (var item in document.TEXTINFOS) |
187 | 185 |
TextModeling(item); |
188 | 186 |
|
189 |
SetSystemEditingCommand(true); |
|
190 |
|
|
191 | 187 |
// LineRun Line Join |
192 | 188 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Join LineRuns"); |
193 | 189 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
... | ... | |
512 | 508 |
GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y); |
513 | 509 |
|
514 | 510 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
511 |
|
|
512 |
if (_LMSymbol != null && _TargetItem != null) |
|
513 |
{ |
|
514 |
symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
|
515 |
LMConnector reModelingConnector = FindBreakLineTarget(symbol, targetSymbol); |
|
516 |
|
|
517 |
if (reModelingConnector != null) |
|
518 |
ReModelingLMConnector(reModelingConnector); |
|
519 |
} |
|
520 |
|
|
515 | 521 |
ReleaseCOMObjects(_TargetItem); |
516 | 522 |
} |
517 | 523 |
else |
... | ... | |
937 | 943 |
LMConnector targetConnector1 = null; |
938 | 944 |
Dictionary<LMConnector, List<double[]>> connectorVertices2 = new Dictionary<LMConnector, List<double[]>>(); |
939 | 945 |
LMConnector targetConnector2 = null; |
940 |
|
|
946 |
|
|
941 | 947 |
Line startBranchLine = null; |
942 | 948 |
Line endBranchLine = null; |
943 | 949 |
|
... | ... | |
1095 | 1101 |
|
1096 | 1102 |
if (_lMConnector != null) |
1097 | 1103 |
{ |
1098 |
foreach (var line in lines) |
|
1099 |
line.SPPID.ModelItemId = _lMConnector.ModelItemID; |
|
1100 |
_lMConnector.Commit(); |
|
1104 |
if (_LMSymbol1 != null || _LMSymbol2 != null) |
|
1105 |
ReModelingLine(lines, _lMConnector, _LMSymbol1, _LMSymbol2); |
|
1106 |
else |
|
1107 |
{ |
|
1108 |
foreach (var line in lines) |
|
1109 |
line.SPPID.ModelItemId = _lMConnector.ModelItemID; |
|
1110 |
_lMConnector.Commit(); |
|
1111 |
} |
|
1101 | 1112 |
if (startBranchLine != null || endBranchLine != null) |
1102 |
BranchLines.Add(new Tuple<string, Line, Line>(_lMConnector.ModelItemID, startBranchLine, endBranchLine)); |
|
1113 |
BranchLines.Add(new Tuple<string, Line, Line>(lines[0].SPPID.ModelItemId, startBranchLine, endBranchLine)); |
|
1114 |
|
|
1103 | 1115 |
} |
1104 | 1116 |
|
1105 | 1117 |
if (_LMSymbol1 != null) |
... | ... | |
1121 | 1133 |
} |
1122 | 1134 |
|
1123 | 1135 |
/// <summary> |
1136 |
/// Symbol에 붙을 경우 Line을 Remodeling 한다. |
|
1137 |
/// </summary> |
|
1138 |
/// <param name="lines"></param> |
|
1139 |
/// <param name="prevLMConnector"></param> |
|
1140 |
/// <param name="startSymbol"></param> |
|
1141 |
/// <param name="endSymbol"></param> |
|
1142 |
private void ReModelingLine(List<Line> lines, LMConnector prevLMConnector, LMSymbol startSymbol, LMSymbol endSymbol) |
|
1143 |
{ |
|
1144 |
|
|
1145 |
string symbolPath = string.Empty; |
|
1146 |
#region get symbol path |
|
1147 |
LMModelItem modelItem = dataSource.GetModelItem(prevLMConnector.ModelItemID); |
|
1148 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
1149 |
{ |
|
1150 |
if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
|
1151 |
{ |
|
1152 |
symbolPath = rep.get_FileName(); |
|
1153 |
break; |
|
1154 |
} |
|
1155 |
} |
|
1156 |
#endregion |
|
1157 |
_LMAItem _LMAItem = _placement.PIDCreateItem(symbolPath); |
|
1158 |
LMConnector newConnector = null; |
|
1159 |
dynamic OID = prevLMConnector.get_GraphicOID(); |
|
1160 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
1161 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
1162 |
int verticesCount = lineStringGeometry.VertexCount; |
|
1163 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
|
1164 |
|
|
1165 |
List<double[]> vertices = new List<double[]>(); |
|
1166 |
for (int i = 1; i <= verticesCount; i++) |
|
1167 |
{ |
|
1168 |
double x = 0; |
|
1169 |
double y = 0; |
|
1170 |
lineStringGeometry.GetVertex(i, ref x, ref y); |
|
1171 |
vertices.Add(new double[] { x, y }); |
|
1172 |
} |
|
1173 |
|
|
1174 |
for (int i = 0; i < vertices.Count; i++) |
|
1175 |
{ |
|
1176 |
double[] points = vertices[i]; |
|
1177 |
// 시작 심볼이 있고 첫번째 좌표일 때 |
|
1178 |
if (startSymbol != null && i == 0) |
|
1179 |
{ |
|
1180 |
SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i + 1][0], vertices[i + 1][1]); |
|
1181 |
if (slopeType == SlopeType.HORIZONTAL) |
|
1182 |
placeRunInputs.AddPoint(points[0], -0.1); |
|
1183 |
else if (slopeType == SlopeType.VERTICAL) |
|
1184 |
placeRunInputs.AddPoint(-0.1, points[1]); |
|
1185 |
else |
|
1186 |
placeRunInputs.AddPoint(points[0], -0.1); |
|
1187 |
|
|
1188 |
placeRunInputs.AddPoint(points[0], points[1]); |
|
1189 |
} |
|
1190 |
// 마지막 심볼이 있고 마지막 좌표일 때 |
|
1191 |
else if (endSymbol != null && i == vertices.Count - 1) |
|
1192 |
{ |
|
1193 |
placeRunInputs.AddPoint(points[0], points[1]); |
|
1194 |
|
|
1195 |
SlopeType slopeType = SPPIDUtil.CalcSlope(points[0], points[1], vertices[i - 1][0], vertices[i - 1][1]); |
|
1196 |
if (slopeType == SlopeType.HORIZONTAL) |
|
1197 |
placeRunInputs.AddPoint(points[0], -0.1); |
|
1198 |
else if (slopeType == SlopeType.VERTICAL) |
|
1199 |
placeRunInputs.AddPoint(-0.1, points[1]); |
|
1200 |
else |
|
1201 |
placeRunInputs.AddPoint(points[0], -0.1); |
|
1202 |
} |
|
1203 |
// 첫번째이며 시작 심볼이 아니고 Connecotr일 경우 |
|
1204 |
else if (i == 0 && prevLMConnector.ConnectItem1SymbolObject != null) |
|
1205 |
placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem1SymbolObject, points[0], points[1]); |
|
1206 |
// 마지막이며 마지막 심볼이 아니고 Connecotr일 경우 |
|
1207 |
else if (i == vertices.Count - 1 && prevLMConnector.ConnectItem2SymbolObject != null) |
|
1208 |
placeRunInputs.AddSymbolTarget(prevLMConnector.ConnectItem2SymbolObject, points[0], points[1]); |
|
1209 |
else |
|
1210 |
placeRunInputs.AddPoint(points[0], points[1]); |
|
1211 |
} |
|
1212 |
|
|
1213 |
_placement.PIDRemovePlacement(prevLMConnector.AsLMRepresentation()); |
|
1214 |
newConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1215 |
|
|
1216 |
ReleaseCOMObjects(placeRunInputs); |
|
1217 |
ReleaseCOMObjects(_LMAItem); |
|
1218 |
ReleaseCOMObjects(modelItem); |
|
1219 |
|
|
1220 |
if (newConnector != null) |
|
1221 |
{ |
|
1222 |
if (startSymbol != null) |
|
1223 |
{ |
|
1224 |
_LMAItem = _placement.PIDCreateItem(symbolPath); |
|
1225 |
placeRunInputs = new PlaceRunInputs(); |
|
1226 |
placeRunInputs.AddSymbolTarget(startSymbol, vertices[0][0], vertices[0][1]); |
|
1227 |
placeRunInputs.AddConnectorTarget(newConnector, vertices[0][0], vertices[0][1]); |
|
1228 |
LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1229 |
if (_LMConnector != null) |
|
1230 |
{ |
|
1231 |
RemoveConnectorForReModelingLine(newConnector); |
|
1232 |
ReleaseCOMObjects(_LMConnector); |
|
1233 |
} |
|
1234 |
ReleaseCOMObjects(placeRunInputs); |
|
1235 |
ReleaseCOMObjects(_LMAItem); |
|
1236 |
} |
|
1237 |
|
|
1238 |
if (endSymbol != null) |
|
1239 |
{ |
|
1240 |
if (startSymbol != null) |
|
1241 |
{ |
|
1242 |
Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(newConnector.ModelItemID); |
|
1243 |
newConnector = dicVertices.First().Key; |
|
1244 |
} |
|
1245 |
|
|
1246 |
_LMAItem = _placement.PIDCreateItem(symbolPath); |
|
1247 |
placeRunInputs = new PlaceRunInputs(); |
|
1248 |
placeRunInputs.AddSymbolTarget(endSymbol, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1]); |
|
1249 |
placeRunInputs.AddConnectorTarget(newConnector, vertices[vertices.Count - 1][0], vertices[vertices.Count - 1][1]); |
|
1250 |
LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1251 |
if (_LMConnector != null) |
|
1252 |
{ |
|
1253 |
RemoveConnectorForReModelingLine(newConnector); |
|
1254 |
ReleaseCOMObjects(_LMConnector); |
|
1255 |
} |
|
1256 |
ReleaseCOMObjects(placeRunInputs); |
|
1257 |
ReleaseCOMObjects(_LMAItem); |
|
1258 |
} |
|
1259 |
|
|
1260 |
foreach (var line in lines) |
|
1261 |
line.SPPID.ModelItemId = newConnector.ModelItemID; |
|
1262 |
ReleaseCOMObjects(newConnector); |
|
1263 |
} |
|
1264 |
|
|
1265 |
ReleaseCOMObjects(modelItem); |
|
1266 |
} |
|
1267 |
|
|
1268 |
/// <summary> |
|
1269 |
/// Remodeling 과정에서 생긴 불필요한 Connector 제거 |
|
1270 |
/// </summary> |
|
1271 |
/// <param name="connector"></param> |
|
1272 |
private void RemoveConnectorForReModelingLine(LMConnector connector) |
|
1273 |
{ |
|
1274 |
Dictionary<LMConnector, List<double[]>> dicVertices = GetPipeRunVertices(connector.ModelItemID); |
|
1275 |
foreach (var item in dicVertices) |
|
1276 |
{ |
|
1277 |
bool result = false; |
|
1278 |
foreach (var point in item.Value) |
|
1279 |
{ |
|
1280 |
if (point[0] < 0 || point[1] < 0) |
|
1281 |
{ |
|
1282 |
result = true; |
|
1283 |
_placement.PIDRemovePlacement(item.Key.AsLMRepresentation()); |
|
1284 |
break; |
|
1285 |
} |
|
1286 |
} |
|
1287 |
|
|
1288 |
if (result) |
|
1289 |
break; |
|
1290 |
} |
|
1291 |
foreach (var item in dicVertices) |
|
1292 |
ReleaseCOMObjects(item.Key); |
|
1293 |
} |
|
1294 |
|
|
1295 |
/// <summary> |
|
1124 | 1296 |
/// Symbol이 모델링된 SPPPID Symbol Object를 반환 - 연결된 Symbol이 ChildSymbol일 수도 있기때문에 메서드 개발 |
1125 | 1297 |
/// </summary> |
1126 | 1298 |
/// <param name="symbol"></param> |
... | ... | |
1463 | 1635 |
private void EndBreakModeling(EndBreak endBreak) |
1464 | 1636 |
{ |
1465 | 1637 |
object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
1466 |
LMConnector targetLMConnector = null; |
|
1467 |
if (ownerObj !=null && ownerObj.GetType() == typeof(Line)) |
|
1468 |
{ |
|
1469 |
Line ownerLine = ownerObj as Line; |
|
1470 |
LMLabelPersist _LmLabelPersist = null; |
|
1471 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(ownerLine.SPPID.ModelItemId); |
|
1472 |
|
|
1473 |
targetLMConnector = FindTargetLMConnectorByPoint(connectorVertices, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
|
1474 |
|
|
1475 |
if (targetLMConnector != null) |
|
1476 |
{ |
|
1477 |
Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
|
1478 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1479 |
} |
|
1480 |
|
|
1481 |
if (_LmLabelPersist != null) |
|
1482 |
{ |
|
1483 |
_LmLabelPersist.Commit(); |
|
1484 |
ReleaseCOMObjects(_LmLabelPersist); |
|
1485 |
} |
|
1486 |
else |
|
1487 |
RetryEndBreakModeling(endBreak, targetLMConnector); |
|
1638 |
object connectedItem = SPPIDUtil.FindObjectByUID(document, endBreak.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE); |
|
1639 |
LMConnector targetLMConnector = FindBreakLineTarget(ownerObj, connectedItem); |
|
1488 | 1640 |
|
1489 |
foreach (var item in connectorVertices) |
|
1490 |
ReleaseCOMObjects(item.Key); |
|
1491 |
|
|
1492 |
} |
|
1493 |
else if (ownerObj != null && ownerObj.GetType() == typeof(Symbol)) |
|
1641 |
if (targetLMConnector != null) |
|
1494 | 1642 |
{ |
1495 |
Symbol ownerSymbol = ownerObj as Symbol; |
|
1496 |
LMSymbol _LMSymbol = dataSource.GetSymbol(ownerSymbol.SPPID.RepresentationId); |
|
1497 |
|
|
1498 |
targetLMConnector = null; |
|
1499 |
double distance = double.MaxValue; |
|
1500 |
|
|
1501 |
foreach (LMConnector connector in _LMSymbol.Avoid1Connectors) |
|
1502 |
{ |
|
1503 |
if (connector.get_ItemStatus() == "Active") |
|
1504 |
{ |
|
1505 |
dynamic OID = connector.get_GraphicOID(); |
|
1506 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
1507 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
1508 |
int verticesCount = lineStringGeometry.VertexCount; |
|
1509 |
double[] vertices = null; |
|
1510 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
|
1511 |
for (int i = 0; i < verticesCount; i++) |
|
1512 |
{ |
|
1513 |
double x = 0; |
|
1514 |
double y = 0; |
|
1515 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
|
1516 |
|
|
1517 |
double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
|
1518 |
if (result < distance) |
|
1519 |
{ |
|
1520 |
targetLMConnector = connector; |
|
1521 |
distance = result; |
|
1522 |
} |
|
1523 |
} |
|
1524 |
} |
|
1525 |
} |
|
1526 |
|
|
1527 |
foreach (LMConnector connector in _LMSymbol.Avoid2Connectors) |
|
1528 |
{ |
|
1529 |
if (connector.get_ItemStatus() == "Active") |
|
1530 |
{ |
|
1531 |
dynamic OID = connector.get_GraphicOID(); |
|
1532 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
1533 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
1534 |
int verticesCount = lineStringGeometry.VertexCount; |
|
1535 |
double[] vertices = null; |
|
1536 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
|
1537 |
for (int i = 0; i < verticesCount; i++) |
|
1538 |
{ |
|
1539 |
double x = 0; |
|
1540 |
double y = 0; |
|
1541 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
|
1542 |
|
|
1543 |
double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
|
1544 |
if (result < distance) |
|
1545 |
{ |
|
1546 |
targetLMConnector = connector; |
|
1547 |
distance = result; |
|
1548 |
} |
|
1549 |
} |
|
1550 |
} |
|
1551 |
} |
|
1552 |
|
|
1553 |
if (targetLMConnector != null) |
|
1554 |
{ |
|
1555 |
LMLabelPersist _LmLabelPersist = null; |
|
1556 |
Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
|
1557 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1558 |
if (_LmLabelPersist != null) |
|
1559 |
{ |
|
1560 |
_LmLabelPersist.Commit(); |
|
1561 |
ReleaseCOMObjects(_LmLabelPersist); |
|
1562 |
} |
|
1563 |
else |
|
1564 |
RetryEndBreakModeling(endBreak, targetLMConnector); |
|
1565 |
} |
|
1566 |
|
|
1567 |
ReleaseCOMObjects(_LMSymbol); |
|
1643 |
Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
|
1644 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1568 | 1645 |
} |
1569 |
|
|
1646 |
|
|
1570 | 1647 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1571 | 1648 |
} |
1572 | 1649 |
|
... | ... | |
1749 | 1826 |
if (upStreamObj != null && |
1750 | 1827 |
downStreamObj != null) |
1751 | 1828 |
{ |
1752 |
LMConnector targetLMConnector = null; |
|
1753 |
LMSymbol upStreamLMSymbol = null; |
|
1754 |
LMSymbol downStreamLMSymbol = null; |
|
1755 |
List<LMConnector> upStreamLMConnectors = null; |
|
1756 |
List<LMConnector> downStreamLMConnectors = null; |
|
1829 |
LMConnector targetLMConnector = FindBreakLineTarget(upStreamObj, downStreamObj); |
|
1757 | 1830 |
|
1758 |
// UpStream = Symbol, DownStream = Symbol 경우 |
|
1759 |
if (upStreamObj.GetType() == typeof(Symbol) && downStreamObj.GetType() == typeof(Symbol)) |
|
1831 |
if (targetLMConnector != null) |
|
1760 | 1832 |
{ |
1761 |
Symbol upStreamSymbol = upStreamObj as Symbol; |
|
1762 |
Symbol downStreamSymbol = downStreamObj as Symbol; |
|
1763 |
if (!string.IsNullOrEmpty(upStreamSymbol.SPPID.RepresentationId) && !string.IsNullOrEmpty(downStreamSymbol.SPPID.RepresentationId)) |
|
1833 |
string MappingPath = specBreak.SPPID.MAPPINGNAME; |
|
1834 |
Array array = new double[] { 0, specBreak.SPPID.ORIGINAL_X, specBreak.SPPID.ORIGINAL_Y }; |
|
1835 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, Rotation: specBreak.ANGLE, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1836 |
|
|
1837 |
if (_LmLabelPersist != null) |
|
1764 | 1838 |
{ |
1765 |
upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
|
1766 |
downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId); |
|
1839 |
specBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id; |
|
1840 |
ReleaseCOMObjects(_LmLabelPersist); |
|
1841 |
} |
|
1767 | 1842 |
|
1768 |
foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
|
1769 |
{ |
|
1770 |
if (connector.get_ItemStatus() == "Active") |
|
1771 |
{ |
|
1772 |
if (connector.AvoidItem1SymbolObject.AsLMRepresentation().Id == downStreamLMSymbol.AsLMRepresentation().Id || |
|
1773 |
connector.AvoidItem2SymbolObject.AsLMRepresentation().Id == downStreamLMSymbol.AsLMRepresentation().Id) |
|
1774 |
targetLMConnector = connector; |
|
1775 |
} |
|
1776 |
} |
|
1843 |
ReleaseCOMObjects(targetLMConnector); |
|
1844 |
} |
|
1845 |
} |
|
1846 |
} |
|
1777 | 1847 |
|
1778 |
foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
|
1779 |
{ |
|
1780 |
if (connector.get_ItemStatus() == "Active") |
|
1781 |
{ |
|
1782 |
if (connector.AvoidItem1SymbolObject.AsLMRepresentation().Id == downStreamLMSymbol.AsLMRepresentation().Id || |
|
1783 |
connector.AvoidItem2SymbolObject.AsLMRepresentation().Id == downStreamLMSymbol.AsLMRepresentation().Id) |
|
1784 |
targetLMConnector = connector; |
|
1785 |
} |
|
1786 |
} |
|
1848 |
private LMConnector FindBreakLineTarget(object targetObj, object connectedObj) |
|
1849 |
{ |
|
1850 |
LMConnector targetConnector = null; |
|
1851 |
Symbol targetSymbol = targetObj as Symbol; |
|
1852 |
Symbol connectedSymbol = connectedObj as Symbol; |
|
1853 |
Line targetLine = targetObj as Line; |
|
1854 |
Line connectedLine = connectedObj as Line; |
|
1855 |
if (targetSymbol != null && connectedSymbol != null) |
|
1856 |
{ |
|
1857 |
LMSymbol targetLMSymbol = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
|
1858 |
LMSymbol connectedLMSymbol = dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId); |
|
1859 |
|
|
1860 |
foreach (LMConnector connector in targetLMSymbol.Avoid1Connectors) |
|
1861 |
{ |
|
1862 |
if (connector.get_ItemStatus() != "Active") |
|
1863 |
continue; |
|
1864 |
|
|
1865 |
if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
|
1866 |
{ |
|
1867 |
targetConnector = connector; |
|
1868 |
break; |
|
1869 |
} |
|
1870 |
else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
|
1871 |
{ |
|
1872 |
targetConnector = connector; |
|
1873 |
break; |
|
1787 | 1874 |
} |
1788 | 1875 |
} |
1789 |
// UpStream = Symbol, DownStream = Line 경우 |
|
1790 |
else if (upStreamObj.GetType() == typeof(Symbol) && downStreamObj.GetType() == typeof(Line))
|
|
1876 |
|
|
1877 |
foreach (LMConnector connector in targetLMSymbol.Avoid2Connectors)
|
|
1791 | 1878 |
{ |
1792 |
Symbol upStreamSymbol = upStreamObj as Symbol; |
|
1793 |
Line downStreamLine = downStreamObj as Line; |
|
1794 |
if (!string.IsNullOrEmpty(upStreamSymbol.SPPID.RepresentationId) && !string.IsNullOrEmpty(downStreamLine.SPPID.ModelItemId)) |
|
1795 |
{ |
|
1796 |
upStreamLMSymbol = dataSource.GetSymbol(upStreamSymbol.SPPID.RepresentationId); |
|
1797 |
downStreamLMConnectors = GetConnectors(downStreamLine.SPPID.ModelItemId); |
|
1879 |
if (connector.get_ItemStatus() != "Active") |
|
1880 |
continue; |
|
1798 | 1881 |
|
1799 |
foreach (LMConnector connector in upStreamLMSymbol.Avoid1Connectors) |
|
1800 |
{ |
|
1801 |
if (connector.get_ItemStatus() == "Active") |
|
1802 |
if (downStreamLMConnectors.Find(x => x.AsLMRepresentation().Id == connector.AsLMRepresentation().Id) != null) |
|
1803 |
targetLMConnector = connector; |
|
1804 |
} |
|
1805 |
foreach (LMConnector connector in upStreamLMSymbol.Avoid2Connectors) |
|
1806 |
{ |
|
1807 |
if (connector.get_ItemStatus() == "Active") |
|
1808 |
if (downStreamLMConnectors.Find(x => x.AsLMRepresentation().Id == connector.AsLMRepresentation().Id) != null) |
|
1809 |
targetLMConnector = connector; |
|
1810 |
} |
|
1882 |
if (connector.ConnectItem1SymbolObject.Id == connectedLMSymbol.Id) |
|
1883 |
{ |
|
1884 |
targetConnector = connector; |
|
1885 |
break; |
|
1886 |
} |
|
1887 |
else if (connector.ConnectItem2SymbolObject.Id == connectedLMSymbol.Id) |
|
1888 |
{ |
|
1889 |
targetConnector = connector; |
|
1890 |
break; |
|
1811 | 1891 |
} |
1812 | 1892 |
} |
1813 |
// UpStream = Line, DownStream = Symbol 경우 |
|
1814 |
else if (upStreamObj.GetType() == typeof(Line) && downStreamObj.GetType() == typeof(Symbol)) |
|
1893 |
|
|
1894 |
ReleaseCOMObjects(targetLMSymbol); |
|
1895 |
ReleaseCOMObjects(connectedLMSymbol); |
|
1896 |
} |
|
1897 |
else if (targetLine != null && connectedLine != null) |
|
1898 |
{ |
|
1899 |
LMModelItem targetModelItem = dataSource.GetModelItem(targetLine.SPPID.ModelItemId); |
|
1900 |
LMModelItem connectedModelItem = dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
|
1901 |
|
|
1902 |
if (targetModelItem != null && connectedModelItem != null) |
|
1815 | 1903 |
{ |
1816 |
Line upStreamLine = upStreamObj as Line; |
|
1817 |
Symbol downStreamSymbol = downStreamObj as Symbol; |
|
1818 |
if (!string.IsNullOrEmpty(upStreamLine.SPPID.ModelItemId) && !string.IsNullOrEmpty(downStreamSymbol.SPPID.RepresentationId)) |
|
1904 |
foreach (LMRepresentation rep in targetModelItem.Representations) |
|
1819 | 1905 |
{ |
1820 |
downStreamLMSymbol = dataSource.GetSymbol(downStreamSymbol.SPPID.RepresentationId);
|
|
1821 |
upStreamLMConnectors = GetConnectors(upStreamLine.SPPID.ModelItemId);
|
|
1906 |
if (targetConnector != null)
|
|
1907 |
break;
|
|
1822 | 1908 |
|
1823 |
foreach (LMConnector connector in downStreamLMSymbol.Avoid1Connectors)
|
|
1909 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
|
|
1824 | 1910 |
{ |
1825 |
if (connector.get_ItemStatus() == "Active") |
|
1826 |
if (upStreamLMConnectors.Find(x => x.AsLMRepresentation().Id == connector.AsLMRepresentation().Id) != null) |
|
1827 |
targetLMConnector = connector; |
|
1828 |
} |
|
1829 |
foreach (LMConnector connector in downStreamLMSymbol.Avoid2Connectors) |
|
1830 |
{ |
|
1831 |
if (connector.get_ItemStatus() == "Active") |
|
1832 |
if (upStreamLMConnectors.Find(x => x.AsLMRepresentation().Id == connector.AsLMRepresentation().Id) != null) |
|
1833 |
targetLMConnector = connector; |
|
1911 |
LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
|
1912 |
|
|
1913 |
if (IsConnected(_LMConnector, connectedModelItem)) |
|
1914 |
targetConnector = _LMConnector; |
|
1915 |
else |
|
1916 |
ReleaseCOMObjects(_LMConnector); |
|
1834 | 1917 |
} |
1835 | 1918 |
} |
1919 |
|
|
1920 |
ReleaseCOMObjects(targetModelItem); |
|
1836 | 1921 |
} |
1837 |
// UpStream = Line, DownStream = Line 경우 |
|
1838 |
else if (upStreamObj.GetType() == typeof(Line) && downStreamObj.GetType() == typeof(Line)) |
|
1922 |
} |
|
1923 |
else |
|
1924 |
{ |
|
1925 |
LMSymbol connectedLMSymbol = connectedSymbol != null ? |
|
1926 |
dataSource.GetSymbol(connectedSymbol.SPPID.RepresentationId) : dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
|
1927 |
LMModelItem targetModelItem = targetLine != null ? |
|
1928 |
dataSource.GetModelItem(targetLine.SPPID.ModelItemId) : dataSource.GetModelItem(connectedLine.SPPID.ModelItemId); |
|
1929 |
if (connectedLMSymbol != null && targetModelItem != null) |
|
1839 | 1930 |
{ |
1840 |
Line upStreamLine = upStreamObj as Line; |
|
1841 |
Line downStreamLine = downStreamObj as Line; |
|
1931 |
foreach (LMConnector connector in connectedLMSymbol.Avoid1Connectors) |
|
1932 |
{ |
|
1933 |
if (IsConnected(connector, targetModelItem)) |
|
1934 |
{ |
|
1935 |
targetConnector = connector; |
|
1936 |
break; |
|
1937 |
} |
|
1938 |
} |
|
1842 | 1939 |
|
1843 |
if (!string.IsNullOrEmpty(upStreamLine.SPPID.ModelItemId) && !string.IsNullOrEmpty(downStreamLine.SPPID.ModelItemId))
|
|
1940 |
if (targetConnector == null)
|
|
1844 | 1941 |
{ |
1845 |
upStreamLMConnectors = GetConnectors(upStreamLine.SPPID.ModelItemId); |
|
1846 |
downStreamLMConnectors = GetConnectors(downStreamLine.SPPID.ModelItemId); |
|
1847 |
List<LMConnector> findUpStreamConnector = new List<LMConnector>(); |
|
1848 |
List<LMConnector> findDownStreamConnector = new List<LMConnector>(); |
|
1849 |
foreach (LMConnector upStreamConnector in upStreamLMConnectors) |
|
1942 |
foreach (LMConnector connector in connectedLMSymbol.Avoid2Connectors) |
|
1850 | 1943 |
{ |
1851 |
foreach (LMConnector downStreamConnector in downStreamLMConnectors)
|
|
1944 |
if (IsConnected(connector, targetModelItem))
|
|
1852 | 1945 |
{ |
1853 |
if (upStreamConnector.ConnectItem1SymbolObject != null && |
|
1854 |
downStreamConnector.ConnectItem1SymbolObject != null && |
|
1855 |
upStreamConnector.ConnectItem1SymbolObject.AsLMRepresentation().Id == downStreamConnector.ConnectItem1SymbolObject.AsLMRepresentation().Id) |
|
1856 |
{ |
|
1857 |
findUpStreamConnector.Add(upStreamConnector); |
|
1858 |
findDownStreamConnector.Add(downStreamConnector); |
|
1859 |
} |
|
1860 |
if (upStreamConnector.ConnectItem1SymbolObject != null && |
|
1861 |
downStreamConnector.ConnectItem2SymbolObject != null && |
|
1862 |
upStreamConnector.ConnectItem1SymbolObject.AsLMRepresentation().Id == downStreamConnector.ConnectItem2SymbolObject.AsLMRepresentation().Id) |
|
1863 |
{ |
|
1864 |
findUpStreamConnector.Add(upStreamConnector); |
|
1865 |
findDownStreamConnector.Add(downStreamConnector); |
|
1866 |
} |
|
1867 |
if (upStreamConnector.ConnectItem2SymbolObject != null && |
|
1868 |
downStreamConnector.ConnectItem1SymbolObject != null && |
|
1869 |
upStreamConnector.ConnectItem2SymbolObject.AsLMRepresentation().Id == downStreamConnector.ConnectItem1SymbolObject.AsLMRepresentation().Id) |
|
1870 |
{ |
|
1871 |
findUpStreamConnector.Add(upStreamConnector); |
|
1872 |
findDownStreamConnector.Add(downStreamConnector); |
|
1873 |
} |
|
1874 |
if (upStreamConnector.ConnectItem2SymbolObject != null && |
|
1875 |
downStreamConnector.ConnectItem2SymbolObject != null && |
|
1876 |
upStreamConnector.ConnectItem2SymbolObject.AsLMRepresentation().Id == downStreamConnector.ConnectItem2SymbolObject.AsLMRepresentation().Id) |
|
1877 |
{ |
|
1878 |
findUpStreamConnector.Add(upStreamConnector); |
|
1879 |
findDownStreamConnector.Add(downStreamConnector); |
|
1880 |
} |
|
1946 |
targetConnector = connector; |
|
1947 |
break; |
|
1881 | 1948 |
} |
1882 | 1949 |
} |
1883 |
|
|
1884 |
findUpStreamConnector = findUpStreamConnector.Distinct().ToList(); |
|
1885 |
findDownStreamConnector = findDownStreamConnector.Distinct().ToList(); |
|
1886 |
|
|
1887 |
if (findUpStreamConnector.Count == 1) |
|
1888 |
targetLMConnector = findUpStreamConnector[0]; |
|
1889 |
else if (findDownStreamConnector.Count == 1) |
|
1890 |
targetLMConnector = findDownStreamConnector[0]; |
|
1891 | 1950 |
} |
1892 | 1951 |
} |
1893 | 1952 |
|
1894 |
if (targetLMConnector != null) |
|
1895 |
{ |
|
1896 |
targetLMConnector = ReModelingLMConnector(targetLMConnector); |
|
1953 |
} |
|
1897 | 1954 |
|
1898 |
string MappingPath = specBreak.SPPID.MAPPINGNAME; |
|
1899 |
Array array = new double[] { 0, specBreak.SPPID.ORIGINAL_X, specBreak.SPPID.ORIGINAL_Y }; |
|
1900 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(MappingPath, ref array, Rotation: specBreak.ANGLE, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1955 |
return targetConnector; |
|
1956 |
} |
|
1901 | 1957 |
|
1902 |
if (_LmLabelPersist != null) |
|
1958 |
private bool IsConnected(LMConnector connector, LMModelItem modelItem) |
|
1959 |
{ |
|
1960 |
bool result = false; |
|
1961 |
|
|
1962 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
1963 |
{ |
|
1964 |
if (result) |
|
1965 |
break; |
|
1966 |
|
|
1967 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
1968 |
{ |
|
1969 |
LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
|
1970 |
|
|
1971 |
if (_LMConnector.ConnectItem1SymbolObject != null && |
|
1972 |
connector.ConnectItem1SymbolObject != null && |
|
1973 |
_LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
|
1903 | 1974 |
{ |
1904 |
specBreak.SPPID.RepresentationId = _LmLabelPersist.AsLMRepresentation().Id; |
|
1905 |
ReleaseCOMObjects(_LmLabelPersist); |
|
1975 |
result = true; |
|
1976 |
ReleaseCOMObjects(_LMConnector); |
|
1977 |
break; |
|
1978 |
} |
|
1979 |
else if (_LMConnector.ConnectItem1SymbolObject != null && |
|
1980 |
connector.ConnectItem2SymbolObject != null && |
|
1981 |
_LMConnector.ConnectItem1SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
|
1982 |
{ |
|
1983 |
result = true; |
|
1984 |
ReleaseCOMObjects(_LMConnector); |
|
1985 |
break; |
|
1986 |
} |
|
1987 |
else if (_LMConnector.ConnectItem2SymbolObject != null && |
|
1988 |
connector.ConnectItem1SymbolObject != null && |
|
1989 |
_LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem1SymbolObject.Id) |
|
1990 |
{ |
|
1991 |
result = true; |
|
1992 |
ReleaseCOMObjects(_LMConnector); |
|
1993 |
break; |
|
1994 |
} |
|
1995 |
else if (_LMConnector.ConnectItem2SymbolObject != null && |
|
1996 |
connector.ConnectItem2SymbolObject != null && |
|
1997 |
_LMConnector.ConnectItem2SymbolObject.Id == connector.ConnectItem2SymbolObject.Id) |
|
1998 |
{ |
|
1999 |
result = true; |
|
2000 |
ReleaseCOMObjects(_LMConnector); |
|
2001 |
break; |
|
1906 | 2002 |
} |
1907 |
} |
|
1908 | 2003 |
|
1909 |
if (upStreamLMSymbol != null) |
|
1910 |
ReleaseCOMObjects(upStreamLMSymbol); |
|
1911 |
if (downStreamLMSymbol != null) |
|
1912 |
ReleaseCOMObjects(downStreamLMSymbol); |
|
1913 |
if (upStreamLMConnectors != null) |
|
1914 |
foreach (var item in upStreamLMConnectors) |
|
1915 |
ReleaseCOMObjects(item); |
|
1916 |
if (downStreamLMConnectors != null) |
|
1917 |
foreach (var item in downStreamLMConnectors) |
|
1918 |
ReleaseCOMObjects(item); |
|
2004 |
ReleaseCOMObjects(_LMConnector); |
|
2005 |
} |
|
1919 | 2006 |
} |
2007 |
|
|
2008 |
|
|
2009 |
return result; |
|
1920 | 2010 |
} |
1921 | 2011 |
|
1922 | 2012 |
/// <summary> |
내보내기 Unified diff