개정판 73415441
dev issue #000 : LabelSymbolModeling 분리 및 공통 메서드 사용으로 수정 / Association 적용
Change-Id: Ibb3dd3578c43d9efc2d863d0c252465ae3415483
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
156 | 156 |
TextModeling(item); |
157 | 157 |
|
158 | 158 |
// LineRun Line Join |
159 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "LineRuns Join");
|
|
159 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Join LineRuns");
|
|
160 | 160 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
161 | 161 |
foreach (LineRun run in lineNumber.RUNS) |
162 | 162 |
JoinRunLine(run); |
... | ... | |
173 | 173 |
// Input Symbol Attribute |
174 | 174 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
175 | 175 |
foreach (var item in document.SYMBOLS) |
176 |
InputSymbolAttribute(item); |
|
176 |
InputSymbolAttribute(item, item.ATTRIBUTES);
|
|
177 | 177 |
|
178 | 178 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Labels Modeling"); |
179 |
#region 임시 Label
|
|
179 |
#region Label Modeling
|
|
180 | 180 |
foreach (var item in document.SYMBOLS) |
181 |
{ |
|
182 |
if (item.SPPID.MAPPINGNAME.Contains("Labels - ")) |
|
183 |
{ |
|
184 |
SPPIDSymbolInfo info = item.SPPID; |
|
185 |
Array points = new double[] { 0, item.SPPID.ORIGINAL_X, item.SPPID.ORIGINAL_Y }; |
|
186 |
BaseModel.Attribute itemAttribute = item.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
|
187 |
if (itemAttribute == null) |
|
188 |
continue; |
|
189 |
string symbolUID = item.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL").VALUE; |
|
190 |
object objectItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
|
191 |
if (objectItem != null) |
|
192 |
{ |
|
193 |
|
|
194 |
string sRep = null; |
|
195 |
if (objectItem.GetType() == typeof(Symbol)) |
|
196 |
sRep = ((Symbol)objectItem).SPPID.RepresentationId; |
|
197 |
else if (objectItem.GetType() == typeof(Equipment)) |
|
198 |
sRep = ((Equipment)objectItem).SPPID.RepresentationId; |
|
199 |
|
|
200 |
if (!string.IsNullOrEmpty(sRep)) |
|
201 |
{ |
|
202 |
bool leaderLine = false; |
|
203 |
SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == item.DBUID); |
|
204 |
if (symbolMapping != null) |
|
205 |
leaderLine = symbolMapping.LEADERLINE; |
|
206 |
|
|
207 |
LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
|
208 |
LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(item.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
|
209 |
LMModelItem _LMModelItem = _TargetItem.ModelItemObject; |
|
210 |
LMAAttributes _Attributes = _LMModelItem.Attributes; |
|
211 |
|
|
212 |
foreach (var attribute in item.ATTRIBUTES) |
|
213 |
{ |
|
214 |
if (!string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
|
215 |
{ |
|
216 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID); |
|
217 |
if (mapping != null) |
|
218 |
{ |
|
219 |
LMAAttribute _LMAAttribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
|
220 |
if (mapping.DisplayAttribute.ToLower().Contains("desc")) |
|
221 |
{ |
|
222 |
if (!DBNull.Value.Equals(_LMAAttribute.get_Value()) && !string.IsNullOrEmpty(_LMAAttribute.get_Value())) |
|
223 |
{ |
|
224 |
string value = _LMAAttribute.get_Value() + "\n" + attribute.VALUE; |
|
225 |
_LMAAttribute.set_Value(value); |
|
226 |
} |
|
227 |
else |
|
228 |
{ |
|
229 |
_LMAAttribute.set_Value(attribute.VALUE); |
|
230 |
} |
|
231 |
} |
|
232 |
else if (_LMAAttribute != null) |
|
233 |
_LMAAttribute.set_Value(attribute.VALUE); |
|
234 |
} |
|
235 |
} |
|
236 |
} |
|
237 |
|
|
238 |
//Leader 선 센터로 |
|
239 |
string OID = _LMLabelPresist.get_GraphicOID(); |
|
240 |
DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
|
241 |
if (dependency != null) |
|
242 |
{ |
|
243 |
bool result = false; |
|
244 |
foreach (var attributes in dependency.AttributeSets) |
|
245 |
{ |
|
246 |
foreach (var attribute in attributes) |
|
247 |
{ |
|
248 |
string name = attribute.Name; |
|
249 |
string value = attribute.GetValue().ToString(); |
|
250 |
if (name == "DrawingItemType" && value == "LabelPersist") |
|
251 |
{ |
|
252 |
foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
|
253 |
{ |
|
254 |
if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
|
255 |
{ |
|
256 |
Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
|
257 |
double prevX = _TargetItem.get_XCoordinate(); |
|
258 |
double prevY = _TargetItem.get_YCoordinate(); |
|
259 |
lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
|
260 |
lineString2D.RemoveVertex(lineString2D.VertexCount); |
|
261 |
result = true; |
|
262 |
break; |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
if (result) |
|
268 |
break; |
|
269 |
} |
|
270 |
|
|
271 |
if (result) |
|
272 |
break; |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
_LMModelItem.Commit(); |
|
278 |
_LMLabelPresist.Commit(); |
|
279 |
ReleaseCOMObjects(_TargetItem); |
|
280 |
ReleaseCOMObjects(_LMLabelPresist); |
|
281 |
ReleaseCOMObjects(_LMModelItem); |
|
282 |
ReleaseCOMObjects(_Attributes); |
|
283 |
} |
|
284 |
} |
|
285 |
} |
|
286 |
|
|
287 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
|
288 |
} |
|
181 |
LabelSymbolModeling(item); |
|
289 | 182 |
#endregion |
290 | 183 |
|
291 | 184 |
|
... | ... | |
508 | 401 |
/// <param name="prevSymbol"></param> |
509 | 402 |
private void SymbolModeling(Symbol symbol, Symbol targetSymbol, Symbol prevSymbol) |
510 | 403 |
{ |
511 |
// 임시 |
|
512 |
if (symbol.SPPID.MAPPINGNAME.Contains("Labels - ")) |
|
404 |
// OWNERSYMBOL Attribute, 값을 가지고 있을 경우 |
|
405 |
BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(attr => attr.ATTRIBUTE == "OWNERSYMBOL"); |
|
406 |
if (itemAttribute != null && string.IsNullOrEmpty(itemAttribute.VALUE) && itemAttribute.VALUE != "None") |
|
513 | 407 |
return; |
514 |
|
|
515 |
if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
|
408 |
// 이미 모델링 됐을 경우 |
|
409 |
else if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId))
|
|
516 | 410 |
return; |
517 | 411 |
|
518 | 412 |
LMSymbol _LMSymbol = null; |
... | ... | |
522 | 416 |
double y = symbol.SPPID.ORIGINAL_Y; |
523 | 417 |
int mirror = 0; |
524 | 418 |
double angle = symbol.ANGLE; |
525 |
// 임시 |
|
419 |
|
|
420 |
// OPC 일경우 180도 일때 Mirror |
|
526 | 421 |
if (mappingPath.Contains("Piping OPC's") && angle == Math.PI) |
527 |
{ |
|
528 | 422 |
mirror = 1; |
529 |
} |
|
530 |
|
|
531 | 423 |
|
532 | 424 |
if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId)) |
533 | 425 |
{ |
... | ... | |
566 | 458 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
567 | 459 |
} |
568 | 460 |
else |
569 |
{ |
|
570 | 461 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
571 |
} |
|
572 | 462 |
|
573 | 463 |
|
574 | 464 |
if (_LMSymbol != null) |
... | ... | |
584 | 474 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
585 | 475 |
} |
586 | 476 |
|
477 |
private void LabelSymbolModeling(Symbol symbol) |
|
478 |
{ |
|
479 |
BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
|
480 |
if (itemAttribute == null || string.IsNullOrEmpty(itemAttribute.VALUE)) |
|
481 |
return; |
|
482 |
|
|
483 |
Array points = new double[] { 0, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y }; |
|
484 |
|
|
485 |
string symbolUID = itemAttribute.VALUE; |
|
486 |
object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
|
487 |
if (targetItem != null) |
|
488 |
{ |
|
489 |
// Object 아이템이 Symbol일 경우 Equipment일 경우 |
|
490 |
string sRep = null; |
|
491 |
if (targetItem.GetType() == typeof(Symbol)) |
|
492 |
sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
|
493 |
else if (targetItem.GetType() == typeof(Equipment)) |
|
494 |
sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
|
495 |
|
|
496 |
if (!string.IsNullOrEmpty(sRep)) |
|
497 |
{ |
|
498 |
// LEADER Line 검사 |
|
499 |
bool leaderLine = false; |
|
500 |
SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
|
501 |
if (symbolMapping != null) |
|
502 |
leaderLine = symbolMapping.LEADERLINE; |
|
503 |
|
|
504 |
// Target Symbol Item 가져오고 Label Modeling |
|
505 |
LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
|
506 |
LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
|
507 |
|
|
508 |
// Target Item에 Label의 Attribute Input |
|
509 |
InputSymbolAttribute(targetItem, symbol.ATTRIBUTES); |
|
510 |
|
|
511 |
//Leader 선 센터로 |
|
512 |
string OID = _LMLabelPresist.get_GraphicOID(); |
|
513 |
DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
|
514 |
if (dependency != null) |
|
515 |
{ |
|
516 |
bool result = false; |
|
517 |
foreach (var attributes in dependency.AttributeSets) |
|
518 |
{ |
|
519 |
foreach (var attribute in attributes) |
|
520 |
{ |
|
521 |
string name = attribute.Name; |
|
522 |
string value = attribute.GetValue().ToString(); |
|
523 |
if (name == "DrawingItemType" && value == "LabelPersist") |
|
524 |
{ |
|
525 |
foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
|
526 |
{ |
|
527 |
if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
|
528 |
{ |
|
529 |
Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
|
530 |
double prevX = _TargetItem.get_XCoordinate(); |
|
531 |
double prevY = _TargetItem.get_YCoordinate(); |
|
532 |
lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
|
533 |
lineString2D.RemoveVertex(lineString2D.VertexCount); |
|
534 |
result = true; |
|
535 |
break; |
|
536 |
} |
|
537 |
} |
|
538 |
} |
|
539 |
|
|
540 |
if (result) |
|
541 |
break; |
|
542 |
} |
|
543 |
|
|
544 |
if (result) |
|
545 |
break; |
|
546 |
} |
|
547 |
} |
|
548 |
|
|
549 |
_LMLabelPresist.Commit(); |
|
550 |
ReleaseCOMObjects(_TargetItem); |
|
551 |
ReleaseCOMObjects(_LMLabelPresist); |
|
552 |
} |
|
553 |
} |
|
554 |
|
|
555 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
|
556 |
} |
|
557 |
|
|
587 | 558 |
/// <summary> |
588 | 559 |
/// Equipment를 실제로 Modeling 메서드 |
589 | 560 |
/// </summary> |
... | ... | |
1788 | 1759 |
/// <summary> |
1789 | 1760 |
/// Symbol Attribute 입력 메서드 |
1790 | 1761 |
/// </summary> |
1791 |
/// <param name="symbol"></param>
|
|
1792 |
private void InputSymbolAttribute(Symbol symbol)
|
|
1762 |
/// <param name="item"></param>
|
|
1763 |
private void InputSymbolAttribute(object targetItem, List<BaseModel.Attribute> targetAttributes)
|
|
1793 | 1764 |
{ |
1794 | 1765 |
try |
1795 | 1766 |
{ |
1796 |
if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
|
1767 |
// Object 아이템이 Symbol일 경우 Equipment일 경우 |
|
1768 |
string sRep = null; |
|
1769 |
if (targetItem.GetType() == typeof(Symbol)) |
|
1770 |
sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
|
1771 |
else if (targetItem.GetType() == typeof(Equipment)) |
|
1772 |
sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
|
1773 |
|
|
1774 |
if (!string.IsNullOrEmpty(sRep)) |
|
1797 | 1775 |
{ |
1798 |
LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId);
|
|
1776 |
LMSymbol _LMSymbol = dataSource.GetSymbol(sRep);
|
|
1799 | 1777 |
LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
1800 | 1778 |
LMAAttributes _Attributes = _LMModelItem.Attributes; |
1801 | 1779 |
|
1802 |
foreach (var item in symbol.PROPERTIES) |
|
1803 |
{ |
|
1804 |
|
|
1805 |
|
|
1806 |
} |
|
1807 |
|
|
1808 |
foreach (var item in symbol.ATTRIBUTES) |
|
1780 |
foreach (var item in targetAttributes) |
|
1809 | 1781 |
{ |
1810 | 1782 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
1811 | 1783 |
if (mapping != null && !string.IsNullOrEmpty(item.VALUE) && item.VALUE != "None") |
1812 | 1784 |
{ |
1813 | 1785 |
LMAAttribute _Attribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
1814 | 1786 |
if (_Attribute != null) |
1815 |
{ |
|
1816 |
// 임시 |
|
1817 |
if (mapping.DisplayAttribute.ToLower().Contains("desc")) |
|
1818 |
{ |
|
1819 |
if (!string.IsNullOrEmpty(item.VALUE)) |
|
1820 |
{ |
|
1821 |
if (!DBNull.Value.Equals(_Attribute.get_Value()) && !string.IsNullOrEmpty(_Attribute.get_Value())) |
|
1822 |
{ |
|
1823 |
string value = _Attribute.get_Value() + "\n" + item.VALUE; |
|
1824 |
_Attribute.set_Value(value); |
|
1825 |
} |
|
1826 |
else |
|
1827 |
{ |
|
1828 |
_Attribute.set_Value(item.VALUE); |
|
1829 |
} |
|
1830 |
} |
|
1831 |
} |
|
1832 |
else |
|
1833 |
{ |
|
1834 |
_Attribute.set_Value(item.VALUE); |
|
1835 |
} |
|
1836 |
} |
|
1787 |
_Attribute.set_Value(item.VALUE); |
|
1837 | 1788 |
} |
1838 | 1789 |
} |
1839 |
|
|
1840 |
foreach (var item in symbol.ASSOCIATIONS) |
|
1841 |
{ |
|
1842 |
|
|
1843 |
} |
|
1844 |
|
|
1845 |
ReleaseCOMObjects(_LMSymbol); |
|
1790 |
_LMModelItem.Commit(); |
|
1791 |
|
|
1846 | 1792 |
ReleaseCOMObjects(_Attributes); |
1847 | 1793 |
ReleaseCOMObjects(_LMModelItem); |
1794 |
ReleaseCOMObjects(_LMSymbol); |
|
1848 | 1795 |
} |
1849 | 1796 |
} |
1850 | 1797 |
catch (Exception ex) |
내보내기 Unified diff