300 |
300 |
private void RunLineModeling()
|
301 |
301 |
{
|
302 |
302 |
List<Line> AllLine = document.LINES.ToList();
|
303 |
|
List<Line> stepLast_Line = document.LINES.FindAll(x => x.CONNECTORS.FindAll(y => y.ConnectedObject != null && y.ConnectedObject.GetType() == typeof(Symbol)).Count == 2 &&
|
304 |
|
!SPPIDUtil.IsBranchedLine(document, x));
|
|
303 |
List<Line> stepLast_Line = document.LINES.FindAll(x => x.CONNECTORS.FindAll(y => y.ConnectedObject != null
|
|
304 |
&& y.ConnectedObject.GetType() == typeof(Symbol)).Count == 2
|
|
305 |
&& !SPPIDUtil.IsBranchedLine(document, x));
|
305 |
306 |
List<Line> step1_Line = AllLine.FindAll(x => !stepLast_Line.Contains(x));
|
306 |
307 |
|
307 |
308 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, step1_Line.Count);
|
... | ... | |
1100 |
1101 |
Log.Write("Drawing name : " + drawingName);
|
1101 |
1102 |
Log.Write("Drawing number : " + drawingNumber);
|
1102 |
1103 |
Thread.Sleep(1000);
|
1103 |
|
newDrawing = application.Drawings.Add(document.Unit, document.Template, drawingNumber, drawingName);
|
|
1104 |
try
|
|
1105 |
{
|
|
1106 |
newDrawing = application.Drawings.Add(document.Unit, document.Template, drawingNumber, drawingName);
|
|
1107 |
}
|
|
1108 |
catch (Exception ex)
|
|
1109 |
{
|
|
1110 |
if (ex.Message == "Invalid procedure call or argument")
|
|
1111 |
{
|
|
1112 |
Exception newEx = new Exception(string.Format("Invalid Unit [0]", document.Unit), ex.InnerException);
|
|
1113 |
throw newEx;
|
|
1114 |
}
|
|
1115 |
else
|
|
1116 |
{
|
|
1117 |
throw ex;
|
|
1118 |
}
|
|
1119 |
}
|
|
1120 |
|
1104 |
1121 |
if (newDrawing != null)
|
1105 |
1122 |
{
|
1106 |
1123 |
document.SPPID_DrawingNumber = drawingNumber;
|
... | ... | |
1362 |
1379 |
{
|
1363 |
1380 |
double currentX = _LMSymbol.get_XCoordinate();
|
1364 |
1381 |
double currentY = _LMSymbol.get_YCoordinate();
|
1365 |
|
|
1366 |
|
|
1367 |
1382 |
}
|
1368 |
1383 |
|
1369 |
1384 |
symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id;
|
... | ... | |
1383 |
1398 |
symbol.SPPID.SPPID_Max_X = range[2];
|
1384 |
1399 |
symbol.SPPID.SPPID_Max_Y = range[3];
|
1385 |
1400 |
|
1386 |
|
foreach (var item in symbol.SPPID.CorrectionX_GroupSymbols)
|
1387 |
|
item.SPPID.ORIGINAL_X = symbol.SPPID.SPPID_X;
|
1388 |
|
foreach (var item in symbol.SPPID.CorrectionY_GroupSymbols)
|
1389 |
|
item.SPPID.ORIGINAL_Y = symbol.SPPID.SPPID_Y;
|
|
1401 |
double xGap = symbol.SPPID.SPPID_X - symbol.SPPID.ORIGINAL_X;
|
|
1402 |
double yGap = symbol.SPPID.SPPID_Y - symbol.SPPID.ORIGINAL_Y;
|
|
1403 |
|
|
1404 |
List<Symbol> xGroupSymbols = symbol.SPPID.CorrectionX_GroupSymbols;
|
|
1405 |
List<Symbol> yGroupSymbols = symbol.SPPID.CorrectionY_GroupSymbols;
|
|
1406 |
xGroupSymbols.Sort(SPPIDUtil.SortSymbolPriority);
|
|
1407 |
yGroupSymbols.Sort(SPPIDUtil.SortSymbolPriority);
|
|
1408 |
int xDrawnCount = xGroupSymbols.Count(c => c.SPPID.RepresentationId != null);
|
|
1409 |
int yDrawnCount = yGroupSymbols.Count(c => c.SPPID.RepresentationId != null);
|
|
1410 |
|
|
1411 |
if (xDrawnCount == 1 || xDrawnCount == 2)
|
|
1412 |
{
|
|
1413 |
for (int i = 0; i < xGroupSymbols.Count; i++)
|
|
1414 |
{
|
|
1415 |
var item = xGroupSymbols[i];
|
|
1416 |
if (!string.IsNullOrWhiteSpace(item.SPPID.RepresentationId)) continue;
|
|
1417 |
|
|
1418 |
if (xDrawnCount == 1)
|
|
1419 |
{
|
|
1420 |
item.SPPID.ORIGINAL_X = symbol.SPPID.SPPID_X;
|
|
1421 |
item.SPPID.ORIGINAL_Y = item.SPPID.ORIGINAL_Y + yGap;
|
|
1422 |
}
|
|
1423 |
else if (xDrawnCount == 2)
|
|
1424 |
{
|
|
1425 |
if (item.SPPID.IsEqualSpacingY)
|
|
1426 |
{
|
|
1427 |
double ppValue = xGroupSymbols[i - 2].SPPID.SPPID_Y != 0 ? xGroupSymbols[i - 2].SPPID.SPPID_Y : xGroupSymbols[i - 2].SPPID.ORIGINAL_Y;
|
|
1428 |
double pValue = xGroupSymbols[i - 1].SPPID.SPPID_Y != 0 ? xGroupSymbols[i - 1].SPPID.SPPID_Y : xGroupSymbols[i - 1].SPPID.ORIGINAL_Y;
|
|
1429 |
double gap = pValue - ppValue;
|
|
1430 |
double value = pValue + gap;
|
|
1431 |
item.SPPID.ORIGINAL_Y = value;
|
|
1432 |
}
|
|
1433 |
}
|
|
1434 |
}
|
|
1435 |
}
|
|
1436 |
|
|
1437 |
if (yDrawnCount == 1 || yDrawnCount == 2)
|
|
1438 |
{
|
|
1439 |
for (int i = 0; i < yGroupSymbols.Count; i++)
|
|
1440 |
{
|
|
1441 |
var item = yGroupSymbols[i];
|
|
1442 |
if (!string.IsNullOrWhiteSpace(item.SPPID.RepresentationId)) continue;
|
|
1443 |
|
|
1444 |
if (yDrawnCount == 1)
|
|
1445 |
{
|
|
1446 |
item.SPPID.ORIGINAL_Y = symbol.SPPID.SPPID_Y;
|
|
1447 |
item.SPPID.ORIGINAL_X = item.SPPID.ORIGINAL_X + xGap;
|
|
1448 |
}
|
|
1449 |
else if (yDrawnCount == 2)
|
|
1450 |
{
|
|
1451 |
if (item.SPPID.IsEqualSpacingX)
|
|
1452 |
{
|
|
1453 |
double ppValue = yGroupSymbols[i - 2].SPPID.SPPID_X != 0 ? yGroupSymbols[i - 2].SPPID.SPPID_X : yGroupSymbols[i - 2].SPPID.ORIGINAL_X;
|
|
1454 |
double pValue = yGroupSymbols[i - 1].SPPID.SPPID_X != 0 ? yGroupSymbols[i - 1].SPPID.SPPID_X : yGroupSymbols[i - 1].SPPID.ORIGINAL_X;
|
|
1455 |
double gap = pValue - ppValue;
|
|
1456 |
double value = pValue + gap;
|
|
1457 |
item.SPPID.ORIGINAL_X = value;
|
|
1458 |
}
|
|
1459 |
}
|
|
1460 |
}
|
|
1461 |
}
|
1390 |
1462 |
|
1391 |
1463 |
ReleaseCOMObjects(_LMSymbol);
|
1392 |
1464 |
}
|
... | ... | |
2114 |
2186 |
List<object> endObjects = new List<object>();
|
2115 |
2187 |
endObjects.Add(symbol);
|
2116 |
2188 |
|
2117 |
|
/// 심볼에 연결되어 있는 항목들을 모델링한다
|
|
2189 |
// 심볼에 연결되어 있는 항목들을 모델링한다
|
2118 |
2190 |
foreach (var connector in symbol.CONNECTORS)
|
2119 |
2191 |
{
|
2120 |
2192 |
object connItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM);
|
... | ... | |
2776 |
2848 |
|
2777 |
2849 |
private void ChangeLineSPPIDCoordinateByConnector(Line line, object connItem, double x, double y, bool changeOtherCoordinate = true)
|
2778 |
2850 |
{
|
|
2851 |
bool isReverseX = line.SPPID.END_X - line.SPPID.START_X < 0;
|
|
2852 |
bool isReverseY = line.SPPID.END_Y - line.SPPID.START_Y < 0;
|
|
2853 |
|
2779 |
2854 |
Connector connector = line.CONNECTORS.Find(z => z.ConnectedObject == connItem);
|
2780 |
2855 |
int index = line.CONNECTORS.IndexOf(connector);
|
2781 |
2856 |
if (index == 0)
|
2782 |
|
{
|
|
2857 |
{
|
2783 |
2858 |
line.SPPID.START_X = x;
|
2784 |
2859 |
line.SPPID.START_Y = y;
|
2785 |
2860 |
if (line.SlopeType == SlopeType.HORIZONTAL && changeOtherCoordinate)
|
|
2861 |
{
|
2786 |
2862 |
line.SPPID.END_Y = y;
|
|
2863 |
// START_X가 END_X 값을 벗어날 경우 END_X 값 보정
|
|
2864 |
if ((line.SPPID.END_X - line.SPPID.START_X) * (!isReverseX ? 1 : -1) <= 0)
|
|
2865 |
{
|
|
2866 |
GridSetting grid = GridSetting.GetInstance();
|
|
2867 |
line.SPPID.END_X = line.SPPID.START_X + (grid.Length * (!isReverseX ? 1 : -1));
|
|
2868 |
}
|
|
2869 |
}
|
2787 |
2870 |
else if (line.SlopeType == SlopeType.VERTICAL && changeOtherCoordinate)
|
|
2871 |
{
|
2788 |
2872 |
line.SPPID.END_X = x;
|
|
2873 |
// START_Y가 END_Y 값을 벗어날 경우 END_Y 값 보정
|
|
2874 |
if ((line.SPPID.END_Y - line.SPPID.START_Y) * (!isReverseY ? 1 : -1) <= 0)
|
|
2875 |
{
|
|
2876 |
GridSetting grid = GridSetting.GetInstance();
|
|
2877 |
line.SPPID.END_Y = line.SPPID.START_Y + (grid.Length * (!isReverseY ? 1 : -1));
|
|
2878 |
}
|
|
2879 |
}
|
2789 |
2880 |
}
|
2790 |
2881 |
else
|
2791 |
2882 |
{
|
2792 |
2883 |
line.SPPID.END_X = x;
|
2793 |
2884 |
line.SPPID.END_Y = y;
|
2794 |
2885 |
if (line.SlopeType == SlopeType.HORIZONTAL && changeOtherCoordinate)
|
|
2886 |
{
|
2795 |
2887 |
line.SPPID.START_Y = y;
|
|
2888 |
// END_X가 START_X 값을 벗어날 경우 START_X 값 보정
|
|
2889 |
if ((line.SPPID.END_X - line.SPPID.START_X) * (isReverseX ? 1 : -1) <= 0)
|
|
2890 |
{
|
|
2891 |
GridSetting grid = GridSetting.GetInstance();
|
|
2892 |
line.SPPID.START_X = line.SPPID.END_X + (grid.Length * (!isReverseX ? 1 : -1));
|
|
2893 |
}
|
|
2894 |
}
|
2796 |
2895 |
else if (line.SlopeType == SlopeType.VERTICAL && changeOtherCoordinate)
|
|
2896 |
{
|
2797 |
2897 |
line.SPPID.START_X = x;
|
|
2898 |
// END_Y가 START_Y 값을 벗어날 경우 START_Y 값 보정
|
|
2899 |
if ((line.SPPID.END_Y - line.SPPID.START_Y) * (isReverseY ? 1 : -1) <= 0)
|
|
2900 |
{
|
|
2901 |
GridSetting grid = GridSetting.GetInstance();
|
|
2902 |
line.SPPID.START_Y = line.SPPID.END_Y + (grid.Length * (!isReverseY ? 1 : -1));
|
|
2903 |
}
|
|
2904 |
}
|
2798 |
2905 |
}
|
2799 |
2906 |
}
|
2800 |
2907 |
|
... | ... | |
6442 |
6549 |
if (!symbols.Contains(item))
|
6443 |
6550 |
tempSymbols.Add(item);
|
6444 |
6551 |
}
|
6445 |
|
tempSymbols.Sort(SortSymbolPriority);
|
|
6552 |
tempSymbols.Sort(SPPIDUtil.SortSymbolPriority);
|
6446 |
6553 |
symbols.AddRange(tempSymbols);
|
6447 |
6554 |
|
6448 |
6555 |
return symbols;
|
... | ... | |
6644 |
6751 |
}
|
6645 |
6752 |
}
|
6646 |
6753 |
|
6647 |
|
private static int SortSymbolPriority(Symbol a, Symbol b)
|
6648 |
|
{
|
6649 |
|
int countA = a.CONNECTORS.FindAll(x => !string.IsNullOrEmpty(x.CONNECTEDITEM) && x.CONNECTEDITEM != "None").Count;
|
6650 |
|
int countB = b.CONNECTORS.FindAll(x => !string.IsNullOrEmpty(x.CONNECTEDITEM) && x.CONNECTEDITEM != "None").Count;
|
6651 |
|
int retval = countB.CompareTo(countA);
|
6652 |
|
if (retval != 0)
|
6653 |
|
return retval;
|
6654 |
|
else
|
6655 |
|
return a.SPPID.ORIGINAL_X.CompareTo(b.SPPID.ORIGINAL_X);
|
6656 |
|
}
|
|
6754 |
|
6657 |
6755 |
|
6658 |
6756 |
private string GetSPPIDFileName(LMModelItem modelItem)
|
6659 |
6757 |
{
|