개정판 0860c756
dev issue #000 : need ReModeling 메서드 수정 및 버그 픽스
Change-Id: I1d3e778feb9335593f8ac20aec5a256fdcbb3e0b
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
690 | 690 |
|
691 | 691 |
string symbolUID = itemAttribute.VALUE; |
692 | 692 |
object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
693 |
if (targetItem != null) |
|
693 |
if (targetItem != null && |
|
694 |
(targetItem.GetType() == typeof(Symbol) || |
|
695 |
targetItem.GetType() == typeof(Equipment))) |
|
694 | 696 |
{ |
695 | 697 |
// Object 아이템이 Symbol일 경우 Equipment일 경우 |
696 | 698 |
string sRep = null; |
... | ... | |
698 | 700 |
sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
699 | 701 |
else if (targetItem.GetType() == typeof(Equipment)) |
700 | 702 |
sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
701 |
|
|
702 | 703 |
if (!string.IsNullOrEmpty(sRep)) |
703 | 704 |
{ |
704 | 705 |
// LEADER Line 검사 |
... | ... | |
755 | 756 |
} |
756 | 757 |
|
757 | 758 |
_LMLabelPresist.Commit(); |
759 |
ReleaseCOMObjects(_LMLabelPresist); |
|
758 | 760 |
} |
759 | 761 |
|
760 | 762 |
ReleaseCOMObjects(_TargetItem); |
761 |
ReleaseCOMObjects(_LMLabelPresist); |
|
762 | 763 |
} |
763 | 764 |
} |
765 |
else if (targetItem != null && targetItem.GetType() == typeof(Line)) |
|
766 |
{ |
|
767 |
Line targetLine = targetItem as Line; |
|
768 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(targetLine.SPPID.ModelItemId); |
|
769 |
LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y); |
|
770 |
if (connectedLMConnector != null) |
|
771 |
{ |
|
772 |
// LEADER Line 검사 |
|
773 |
bool leaderLine = false; |
|
774 |
SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
|
775 |
if (symbolMapping != null) |
|
776 |
leaderLine = symbolMapping.LEADERLINE; |
|
777 |
|
|
778 |
LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
|
779 |
if (_LMLabelPresist != null) |
|
780 |
{ |
|
781 |
_LMLabelPresist.Commit(); |
|
782 |
ReleaseCOMObjects(_LMLabelPresist); |
|
783 |
} |
|
784 |
ReleaseCOMObjects(connectedLMConnector); |
|
785 |
} |
|
786 |
|
|
787 |
foreach (var item in connectorVertices) |
|
788 |
if (item.Key != null) |
|
789 |
ReleaseCOMObjects(item.Key); |
|
790 |
} |
|
764 | 791 |
|
765 | 792 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
766 | 793 |
} |
... | ... | |
1107 | 1134 |
|
1108 | 1135 |
if (_lMConnector != null) |
1109 | 1136 |
{ |
1137 |
if (lines.Find(x => x.UID == "d4bea462-44cc-473d-8fe2-fb2e98009578") != null) |
|
1138 |
{ |
|
1139 |
|
|
1140 |
} |
|
1110 | 1141 |
bool bStart = false; |
1111 | 1142 |
bool bEnd = false; |
1112 | 1143 |
|
1113 |
NeedReModeling(lines, _LMSymbol1, _LMSymbol2, ref bStart, ref bEnd); |
|
1144 |
NeedReModeling(lines[0], _LMSymbol1, ref bStart); |
|
1145 |
NeedReModeling(lines[lines.Count - 1], _LMSymbol2, ref bEnd); |
|
1114 | 1146 |
|
1115 | 1147 |
if (bStart || bEnd) |
1116 | 1148 |
ReModelingLine(lines, _lMConnector, _LMSymbol1, _LMSymbol2, bStart, bEnd); |
... | ... | |
1143 | 1175 |
ReleaseCOMObjects(_LMAItem); |
1144 | 1176 |
} |
1145 | 1177 |
|
1146 |
private void NeedReModeling(List<Line> lines, LMSymbol startSymbol, LMSymbol endSymbol,ref bool bStart, ref bool bEnd)
|
|
1178 |
private void NeedReModeling(Line line, LMSymbol symbol, ref bool result)
|
|
1147 | 1179 |
{ |
1148 |
if (startSymbol != null)
|
|
1180 |
if (symbol != null) |
|
1149 | 1181 |
{ |
1150 |
string startSymbolUID = document.SYMBOLS.Find(x => x.SPPID.RepresentationId == startSymbol.AsLMRepresentation().Id).UID;
|
|
1151 |
string startLineUID = lines[0].UID;
|
|
1182 |
string symbolUID = document.SYMBOLS.Find(x => x.SPPID.RepresentationId == symbol.AsLMRepresentation().Id).UID;
|
|
1183 |
string lineUID = line.UID;
|
|
1152 | 1184 |
|
1153 | 1185 |
SpecBreak startSpecBreak = document.SpecBreaks.Find(x => |
1154 |
(x.DownStreamUID == startSymbolUID || x.UpStreamUID == startSymbolUID) &&
|
|
1155 |
(x.DownStreamUID == startLineUID || x.UpStreamUID == startLineUID));
|
|
1186 |
(x.DownStreamUID == symbolUID || x.UpStreamUID == symbolUID) &&
|
|
1187 |
(x.DownStreamUID == lineUID || x.UpStreamUID == lineUID));
|
|
1156 | 1188 |
|
1157 | 1189 |
EndBreak startEndBreak = document.EndBreaks.Find(x => |
1158 |
(x.OWNER == startSymbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == startSymbolUID) &&
|
|
1159 |
(x.OWNER == startLineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == startLineUID));
|
|
1190 |
(x.OWNER == symbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == symbolUID) &&
|
|
1191 |
(x.OWNER == lineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == lineUID));
|
|
1160 | 1192 |
|
1161 | 1193 |
if (startSpecBreak != null || startEndBreak != null) |
1162 |
bStart = true; |
|
1163 |
} |
|
1164 |
|
|
1165 |
if (endSymbol != null) |
|
1166 |
{ |
|
1167 |
string endSymbolUID = document.SYMBOLS.Find(x => x.SPPID.RepresentationId == endSymbol.AsLMRepresentation().Id).UID; |
|
1168 |
string endLineUID = lines[lines.Count - 1].UID; |
|
1169 |
|
|
1170 |
SpecBreak endSpecBreak = document.SpecBreaks.Find(x => |
|
1171 |
(x.DownStreamUID == endSymbolUID || x.UpStreamUID == endSymbolUID) && |
|
1172 |
(x.DownStreamUID == endLineUID || x.UpStreamUID == endLineUID)); |
|
1173 |
|
|
1174 |
EndBreak endEndBreak = document.EndBreaks.Find(x => |
|
1175 |
(x.OWNER == endSymbolUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == endSymbolUID) && |
|
1176 |
(x.OWNER == endLineUID || x.PROPERTIES.Find(y => y.ATTRIBUTE == "Connected Item").VALUE == endLineUID)); |
|
1177 |
|
|
1178 |
if (endSpecBreak != null || endEndBreak != null) |
|
1179 |
bEnd = true; |
|
1194 |
result = true; |
|
1180 | 1195 |
} |
1181 | 1196 |
} |
1182 |
|
|
1197 |
|
|
1183 | 1198 |
/// <summary> |
1184 | 1199 |
/// Symbol에 붙을 경우 Line을 Remodeling 한다. |
1185 | 1200 |
/// </summary> |
... | ... | |
1424 | 1439 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
1425 | 1440 |
|
1426 | 1441 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
1442 |
if (lines.Find(x => x.UID == "d4bea462-44cc-473d-8fe2-fb2e98009578") != null) |
|
1443 |
{ |
|
1427 | 1444 |
|
1445 |
} |
|
1428 | 1446 |
LMConnector _StartConnector = null; |
1429 | 1447 |
LMConnector _EndConnector = null; |
1430 | 1448 |
double lengthStart = double.MaxValue; |
... | ... | |
1513 | 1531 |
// Branch 시작 Connector |
1514 | 1532 |
if (_StartConnector != null) |
1515 | 1533 |
BranchLineModelingByConnector(branch, _StartConnector, startPoints, true); |
1516 |
|
|
1517 | 1534 |
// Branch 끝 Connector |
1518 |
if (_EndConnector != null) |
|
1535 |
else if (_EndConnector != null)
|
|
1519 | 1536 |
BranchLineModelingByConnector(branch, _EndConnector, endPoints, false); |
1520 | 1537 |
} |
1521 | 1538 |
#endregion |
... | ... | |
1540 | 1557 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
1541 | 1558 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
1542 | 1559 |
LMConnector _SameRunTargetConnector = null; |
1543 |
LMSymbol _SameRunTargetSymbol = null; |
|
1560 |
LMSymbol _SameRunTargetLMSymbol = null; |
|
1561 |
Symbol _SameRunTargetSymbol = null; |
|
1544 | 1562 |
Dictionary<LMConnector, List<double[]>> branchConnectorVertices = null; |
1545 | 1563 |
LMConnector _BranchTargetConnector = null; |
1546 | 1564 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
... | ... | |
1579 | 1597 |
Symbol symbol = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Symbol; |
1580 | 1598 |
if (symbol != null) |
1581 | 1599 |
{ |
1582 |
_SameRunTargetSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
|
1600 |
_SameRunTargetSymbol = symbol; |
|
1601 |
_SameRunTargetLMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
|
1583 | 1602 |
break; |
1584 | 1603 |
} |
1585 | 1604 |
} |
... | ... | |
1606 | 1625 |
points[points.Count - 2][1]); |
1607 | 1626 |
} |
1608 | 1627 |
|
1628 |
|
|
1629 |
bool bNeedRemodeling = false; |
|
1630 |
if (_SameRunTargetLMSymbol != null) |
|
1631 |
{ |
|
1632 |
Line line = lines.Find(x => x.CONNECTORS.Find(y => y.CONNECTEDITEM == _SameRunTargetSymbol.UID) != null); |
|
1633 |
NeedReModeling(line, _SameRunTargetLMSymbol, ref bNeedRemodeling); |
|
1634 |
} |
|
1635 |
|
|
1636 |
|
|
1637 |
|
|
1609 | 1638 |
for (int i = 0; i < points.Count; i++) |
1610 | 1639 |
{ |
1611 | 1640 |
double[] point = points[i]; |
... | ... | |
1621 | 1650 |
{ |
1622 | 1651 |
placeRunInputs.AddPoint(point[0], point[1]); |
1623 | 1652 |
} |
1624 |
|
|
1625 | 1653 |
} |
1626 | 1654 |
else |
1627 | 1655 |
{ |
1628 | 1656 |
if (_SameRunTargetConnector != null) |
1629 | 1657 |
placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1]); |
1630 |
else if (_SameRunTargetSymbol != null) |
|
1631 |
placeRunInputs.AddSymbolTarget(_SameRunTargetSymbol, point[0], point[1]); |
|
1658 |
else if (_SameRunTargetLMSymbol != null && bNeedRemodeling) |
|
1659 |
{ |
|
1660 |
SlopeType slopeType = SPPIDUtil.CalcSlope(point[0], point[1], points[i + 1][0], points[i + 1][1]); |
|
1661 |
if (slopeType == SlopeType.HORIZONTAL) |
|
1662 |
placeRunInputs.AddPoint(point[0], -0.1); |
|
1663 |
else if (slopeType == SlopeType.VERTICAL) |
|
1664 |
placeRunInputs.AddPoint(-0.1, point[1]); |
|
1665 |
else |
|
1666 |
placeRunInputs.AddPoint(point[0], -0.1); |
|
1667 |
|
|
1668 |
placeRunInputs.AddPoint(point[0], point[1]); |
|
1669 |
} |
|
1670 |
else if (_SameRunTargetLMSymbol != null) |
|
1671 |
placeRunInputs.AddSymbolTarget(_SameRunTargetLMSymbol, point[0], point[1]); |
|
1632 | 1672 |
else |
1633 | 1673 |
placeRunInputs.AddPoint(point[0], point[1]); |
1634 | 1674 |
} |
... | ... | |
1639 | 1679 |
{ |
1640 | 1680 |
if (_SameRunTargetConnector != null) |
1641 | 1681 |
placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1]); |
1642 |
else if (_SameRunTargetSymbol != null) |
|
1643 |
placeRunInputs.AddSymbolTarget(_SameRunTargetSymbol, point[0], point[1]); |
|
1682 |
else if (_SameRunTargetLMSymbol != null && bNeedRemodeling) |
|
1683 |
{ |
|
1684 |
placeRunInputs.AddPoint(point[0], point[1]); |
|
1685 |
|
|
1686 |
SlopeType slopeType = SPPIDUtil.CalcSlope(point[0], point[1], points[i - 1][0], points[i - 1][1]); |
|
1687 |
if (slopeType == SlopeType.HORIZONTAL) |
|
1688 |
placeRunInputs.AddPoint(point[0], -0.1); |
|
1689 |
else if (slopeType == SlopeType.VERTICAL) |
|
1690 |
placeRunInputs.AddPoint(-0.1, point[1]); |
|
1691 |
else |
|
1692 |
placeRunInputs.AddPoint(point[0], -0.1); |
|
1693 |
} |
|
1694 |
else if (_SameRunTargetLMSymbol != null) |
|
1695 |
placeRunInputs.AddSymbolTarget(_SameRunTargetLMSymbol, point[0], point[1]); |
|
1644 | 1696 |
else |
1645 | 1697 |
placeRunInputs.AddPoint(point[0], point[1]); |
1646 | 1698 |
} |
... | ... | |
1670 | 1722 |
} |
1671 | 1723 |
else |
1672 | 1724 |
{ |
1725 |
if (_SameRunTargetLMSymbol != null && bNeedRemodeling) |
|
1726 |
{ |
|
1727 |
string symbolPath = string.Empty; |
|
1728 |
#region get symbol path |
|
1729 |
LMModelItem modelItem = dataSource.GetModelItem(_LMConnector.ModelItemID); |
|
1730 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
1731 |
{ |
|
1732 |
if (!DBNull.Value.Equals(rep.get_FileName()) && !string.IsNullOrEmpty(rep.get_FileName())) |
|
1733 |
{ |
|
1734 |
symbolPath = rep.get_FileName(); |
|
1735 |
break; |
|
1736 |
} |
|
1737 |
} |
|
1738 |
ReleaseCOMObjects(modelItem); |
|
1739 |
#endregion |
|
1740 |
|
|
1741 |
double[] point = null; |
|
1742 |
if (IsStart) |
|
1743 |
point = points[points.Count - 1]; |
|
1744 |
else |
|
1745 |
point = points[0]; |
|
1746 |
|
|
1747 |
_LMAItem = _placement.PIDCreateItem(symbolPath); |
|
1748 |
placeRunInputs = new PlaceRunInputs(); |
|
1749 |
placeRunInputs.AddSymbolTarget(_SameRunTargetLMSymbol, point[0], point[1]); |
|
1750 |
placeRunInputs.AddConnectorTarget(_LMConnector, point[0], point[1]); |
|
1751 |
LMConnector _ZeroLengthLMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1752 |
if (_ZeroLengthLMConnector != null) |
|
1753 |
{ |
|
1754 |
RemoveConnectorForReModelingLine(_LMConnector); |
|
1755 |
ZeroLengthModelItemID.Add(_ZeroLengthLMConnector.ModelItemID); |
|
1756 |
ReleaseCOMObjects(_ZeroLengthLMConnector); |
|
1757 |
} |
|
1758 |
ReleaseCOMObjects(placeRunInputs); |
|
1759 |
ReleaseCOMObjects(_LMAItem); |
|
1760 |
} |
|
1761 |
|
|
1673 | 1762 |
foreach (var item in lines) |
1674 | 1763 |
item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
1675 | 1764 |
} |
... | ... | |
1684 | 1773 |
ReleaseCOMObjects(_BranchTargetConnector); |
1685 | 1774 |
if (_SameRunTargetConnector != null) |
1686 | 1775 |
ReleaseCOMObjects(_SameRunTargetConnector); |
1687 |
if (_SameRunTargetSymbol != null) |
|
1688 |
ReleaseCOMObjects(_SameRunTargetSymbol); |
|
1776 |
if (_SameRunTargetLMSymbol != null)
|
|
1777 |
ReleaseCOMObjects(_SameRunTargetLMSymbol);
|
|
1689 | 1778 |
foreach (var item in connectorVertices) |
1690 | 1779 |
ReleaseCOMObjects(item.Key); |
1691 | 1780 |
foreach (var item in branchConnectorVertices) |
... | ... | |
2863 | 2952 |
private void TextModeling(Text text) |
2864 | 2953 |
{ |
2865 | 2954 |
LMSymbol _LMSymbol = null; |
2955 |
LMConnector connectedLMConnector = null; |
|
2866 | 2956 |
try |
2867 | 2957 |
{ |
2868 | 2958 |
//if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
... | ... | |
2907 | 2997 |
} |
2908 | 2998 |
else if (owner.GetType() == typeof(Line)) |
2909 | 2999 |
{ |
3000 |
Line line = owner as Line; |
|
3001 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
|
3002 |
connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y); |
|
2910 | 3003 |
|
3004 |
if (connectedLMConnector != null) |
|
3005 |
{ |
|
3006 |
Association association = line.ASSOCIATIONS.Find(x => x.VALUE == text.UID); |
|
3007 |
List<BaseModel.Attribute> attributes = line.ATTRIBUTES.FindAll(x => x.ATTRIBUTETYPE == association.TYPE); |
|
3008 |
AttributeMapping mapping = null; |
|
3009 |
foreach (var attribute in attributes) |
|
3010 |
{ |
|
3011 |
if (string.IsNullOrEmpty(attribute.VALUE) || attribute.VALUE == "None") |
|
3012 |
continue; |
|
3013 |
|
|
3014 |
mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
|
3015 |
if (mapping != null) |
|
3016 |
break; |
|
3017 |
} |
|
3018 |
|
|
3019 |
if (mapping != null) |
|
3020 |
{ |
|
3021 |
double x = 0; |
|
3022 |
double y = 0; |
|
3023 |
|
|
3024 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
|
3025 |
Array array = new double[] { 0, x, y }; |
|
3026 |
|
|
3027 |
LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
|
3028 |
if (_LMLabelPersist != null) |
|
3029 |
{ |
|
3030 |
_LMLabelPersist.Commit(); |
|
3031 |
ReleaseCOMObjects(_LMLabelPersist); |
|
3032 |
} |
|
3033 |
} |
|
3034 |
} |
|
2911 | 3035 |
} |
2912 | 3036 |
} |
2913 | 3037 |
else |
DTI_PID/SPPIDConverter/BaseModel/Document.cs | ||
---|---|---|
237 | 237 |
else |
238 | 238 |
line.FLOWMARK = false; |
239 | 239 |
|
240 |
SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS); |
|
240 | 241 |
SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS); |
242 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES); |
|
241 | 243 |
LINES.Add(line); |
242 | 244 |
} |
243 | 245 |
} |
DTI_PID/SPPIDConverter/BaseModel/Line.cs | ||
---|---|---|
20 | 20 |
private int _FLOWMARK_PERCENT; |
21 | 21 |
private List<Connector> _CONNECTORS = new List<Connector>(); |
22 | 22 |
private SPPIDLineInfo _SPPID; |
23 |
private List<Association> _ASSOCIATIONS = new List<Association>(); |
|
24 |
private List<Attribute> _ATTRIBUTES = new List<Attribute>(); |
|
23 | 25 |
|
24 | 26 |
public string OWNER { get => _OWNER; set => _OWNER = value; } |
25 | 27 |
public string UID { get => _UID; set => _UID = value; } |
... | ... | |
33 | 35 |
public SPPIDLineInfo SPPID { get => _SPPID; set => _SPPID = value; } |
34 | 36 |
public bool FLOWMARK { get => _FLOWMARK; set => _FLOWMARK = value; } |
35 | 37 |
public int FLOWMARK_PERCENT { get => _FLOWMARK_PERCENT; set => _FLOWMARK_PERCENT = value; } |
38 |
public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; } |
|
39 |
public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; } |
|
36 | 40 |
} |
37 | 41 |
} |
내보내기 Unified diff