개정판 0bbd73b5
dev issue #497 : snap Grid (Line) 기능 추가
Change-Id: I5caa29df7637d29b0d5f04f150867d93db31f588
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
861 | 861 |
Line startBranchLine = null; |
862 | 862 |
Line endBranchLine = null; |
863 | 863 |
|
864 |
// Type, TargetObjet, x, y |
|
865 |
List<Tuple<string, object, double, double>> linePointInfo = new List<Tuple<string, object, double, double>>();
|
|
866 |
|
|
864 |
// Type, Line, TargetObjet, x, y
|
|
865 |
List<Tuple<string, Line, object, double, double>> linePointInfo = new List<Tuple<string, Line, object, double, double>>();
|
|
866 |
// Point 정리 |
|
867 | 867 |
for (int i = 0; i < lines.Count; i++) |
868 | 868 |
{ |
869 | 869 |
Line line = lines[i]; |
... | ... | |
887 | 887 |
line.SPPID.START_Y = y; |
888 | 888 |
} |
889 | 889 |
|
890 |
linePointInfo.Add(new Tuple<string, object, double, double>("SYMBOL", _LMSymbol1, x, y));
|
|
890 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>("SYMBOL", line, _LMSymbol1, x, y));
|
|
891 | 891 |
} |
892 | 892 |
else |
893 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
893 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
894 | 894 |
} |
895 | 895 |
else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
896 | 896 |
{ |
... | ... | |
898 | 898 |
targetConnector1 = FindTargetLMConnector(connectorVertices1, line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
899 | 899 |
|
900 | 900 |
if (targetConnector1 != null) |
901 |
linePointInfo.Add(new Tuple<string, object, double, double>("LINE", targetConnector1, line.SPPID.START_X, line.SPPID.START_Y));
|
|
901 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>("LINE", line, targetConnector1, line.SPPID.START_X, line.SPPID.START_Y));
|
|
902 | 902 |
else |
903 | 903 |
{ |
904 | 904 |
startBranchLine = connItem as Line; |
905 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
905 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
906 | 906 |
} |
907 | 907 |
} |
908 | 908 |
else |
909 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
909 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
910 | 910 |
|
911 | 911 |
} |
912 | 912 |
if (i + 1 == lines.Count) |
... | ... | |
915 | 915 |
object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[1].CONNECTEDITEM); |
916 | 916 |
|
917 | 917 |
if (i != 0) |
918 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
918 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.START_X, line.SPPID.START_Y));
|
|
919 | 919 |
|
920 | 920 |
if (connItem != null && connItem.GetType() == typeof(Symbol)) |
921 | 921 |
{ |
... | ... | |
933 | 933 |
line.SPPID.END_Y = y; |
934 | 934 |
} |
935 | 935 |
|
936 |
linePointInfo.Add(new Tuple<string, object, double, double>("SYMBOL", _LMSymbol2, x, y));
|
|
936 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>("SYMBOL", line, _LMSymbol2, x, y));
|
|
937 | 937 |
} |
938 | 938 |
else |
939 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.END_X, line.SPPID.END_Y));
|
|
939 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.END_X, line.SPPID.END_Y));
|
|
940 | 940 |
} |
941 | 941 |
else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
942 | 942 |
{ |
... | ... | |
944 | 944 |
targetConnector2 = FindTargetLMConnector(connectorVertices2, line.SPPID.END_X, line.SPPID.END_Y, line.SPPID.START_X, line.SPPID.START_Y); |
945 | 945 |
|
946 | 946 |
if (targetConnector2 != null) |
947 |
linePointInfo.Add(new Tuple<string, object, double, double>("LINE", targetConnector2, line.SPPID.END_X, line.SPPID.END_Y));
|
|
947 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>("LINE", line, targetConnector2, line.SPPID.END_X, line.SPPID.END_Y));
|
|
948 | 948 |
else |
949 | 949 |
{ |
950 | 950 |
endBranchLine = connItem as Line; |
951 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.END_X, line.SPPID.END_Y));
|
|
951 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.END_X, line.SPPID.END_Y));
|
|
952 | 952 |
} |
953 | 953 |
} |
954 | 954 |
else |
955 |
linePointInfo.Add(new Tuple<string, object, double, double>(null, null, line.SPPID.END_X, line.SPPID.END_Y));
|
|
955 |
linePointInfo.Add(new Tuple<string, Line, object, double, double>(null, line, null, line.SPPID.END_X, line.SPPID.END_Y));
|
|
956 | 956 |
} |
957 | 957 |
} |
958 | 958 |
|
959 |
double prevX = double.NaN; |
|
960 |
double prevY = double.NaN; |
|
961 |
SlopeType prevSlopeType = SlopeType.None; |
|
959 | 962 |
for (int i = 0; i < linePointInfo.Count; i++) |
960 | 963 |
{ |
961 |
Tuple<string, object, double, double> item = linePointInfo[i]; |
|
964 |
Tuple<string, Line, object, double, double> item = linePointInfo[i]; |
|
965 |
Line line = item.Item2; |
|
966 |
double x = item.Item4; |
|
967 |
double y = item.Item5; |
|
968 |
SlopeType slopeType = SPPIDUtil.CalcSlope(line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
|
969 |
// Symbol일 경우 바로 Input Point |
|
962 | 970 |
if (item.Item1 == "SYMBOL") |
963 |
placeRunInputs.AddSymbolTarget(item.Item2 as LMSymbol, item.Item3, item.Item4); |
|
964 |
else if (item.Item1 == "LINE") |
|
965 |
placeRunInputs.AddConnectorTarget(item.Item2 as LMConnector, item.Item3, item.Item4); |
|
971 |
{ |
|
972 |
placeRunInputs.AddSymbolTarget(item.Item3 as LMSymbol, x, y); |
|
973 |
prevX = x; |
|
974 |
prevY = y; |
|
975 |
prevSlopeType = slopeType; |
|
976 |
continue; |
|
977 |
} |
|
978 |
|
|
979 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
980 |
// i == 0은 그대로 사용 |
|
981 |
if (i != 0) |
|
982 |
{ |
|
983 |
Tuple<string, Line, object, double, double> prevItem = linePointInfo[i - 1]; |
|
984 |
// y 좌표가 같아야함 |
|
985 |
if (prevSlopeType == SlopeType.HORIZONTAL) |
|
986 |
y = prevY; |
|
987 |
else if (prevSlopeType == SlopeType.VERTICAL) |
|
988 |
x = prevX; |
|
989 |
|
|
990 |
if (i + 1 == linePointInfo.Count - 1 && linePointInfo[i + 1].Item1 == "SYMBOL") |
|
991 |
{ |
|
992 |
Line nextLine = linePointInfo[i + 1].Item2; |
|
993 |
SlopeType nextSlopeType = SPPIDUtil.CalcSlope(nextLine.SPPID.START_X, nextLine.SPPID.START_Y, nextLine.SPPID.END_X, nextLine.SPPID.END_Y); |
|
994 |
if (prevSlopeType == SlopeType.HORIZONTAL) |
|
995 |
y = linePointInfo[i + 1].Item5; |
|
996 |
else if (prevSlopeType == SlopeType.VERTICAL) |
|
997 |
x = linePointInfo[i + 1].Item4; |
|
998 |
} |
|
999 |
} |
|
1000 |
|
|
1001 |
if (item.Item1 == "LINE") |
|
1002 |
placeRunInputs.AddConnectorTarget(item.Item3 as LMConnector, x, y); |
|
966 | 1003 |
else |
967 |
placeRunInputs.AddPoint(item.Item3, item.Item4); |
|
1004 |
placeRunInputs.AddPoint(x, y); |
|
1005 |
|
|
1006 |
prevX = x; |
|
1007 |
prevY = y; |
|
1008 |
prevSlopeType = slopeType; |
|
968 | 1009 |
} |
969 | 1010 |
|
970 | 1011 |
LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs | ||
---|---|---|
164 | 164 |
else |
165 | 165 |
{ |
166 | 166 |
double angle = Math.Atan(Math.Abs(y2 - y1) / Math.Abs(x2 - x1)) * 180 / Math.PI; |
167 |
if (angle <= 2)
|
|
167 |
if (angle <= 10)
|
|
168 | 168 |
return SlopeType.HORIZONTAL; |
169 |
else if (angle >= 88)
|
|
169 |
else if (angle >= 80)
|
|
170 | 170 |
return SlopeType.VERTICAL; |
171 | 171 |
else |
172 | 172 |
return SlopeType.Slope; |
내보내기 Unified diff