개정판 5b161eb1
Revert test source
Change-Id: Ia650f492d4447e6869355f4000cdc042d4394ed8
DTI_PID/SPPIDConverter/ConverterDocking.cs | ||
---|---|---|
1095 | 1095 |
#endregion |
1096 | 1096 |
|
1097 | 1097 |
#region SpecBreak |
1098 |
//private void btnSpecBreakRelocation_Click(object sender, EventArgs e) |
|
1099 |
//{ |
|
1100 |
// dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application"); |
|
1101 |
// WrapperApplication wApp = new WrapperApplication(dApplication.Application); |
|
1102 |
// application = wApp.RADApplication; |
|
1103 |
|
|
1104 |
// int count = application.ActiveSelectSet.Count; |
|
1105 |
// int dependencyCount = 0; |
|
1106 |
// foreach (var item in application.ActiveSelectSet) |
|
1107 |
// if (item.GetType() == typeof(DependencyObject)) |
|
1108 |
// dependencyCount++; |
|
1109 |
|
|
1110 |
// if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject)) |
|
1111 |
// { |
|
1112 |
// MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1113 |
// return; |
|
1114 |
// } |
|
1115 |
|
|
1116 |
// if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) && |
|
1117 |
// (dependencyCount == 2 || dependencyCount == 3)) |
|
1118 |
// { |
|
1119 |
// Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d; |
|
1120 |
|
|
1121 |
// if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\")) |
|
1122 |
// { |
|
1123 |
// MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1124 |
// return; |
|
1125 |
// } |
|
1126 |
|
|
1127 |
// DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject; |
|
1128 |
// DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject; |
|
1129 |
// DependencyObject dependency3 = null; |
|
1130 |
// if (count == 4) |
|
1131 |
// dependency3 = application.ActiveSelectSet[3] as DependencyObject; |
|
1132 |
|
|
1133 |
// application.ActiveSelectSet.RemoveAll(); |
|
1134 |
// double angle = symbol.Angle; |
|
1135 |
// if (symbol.GetTransform().HasReflection) |
|
1136 |
// angle += Math.PI; |
|
1137 |
|
|
1138 |
// double degree = double.NaN; |
|
1139 |
// if (angle > -0.1 && angle < 0.1) |
|
1140 |
// degree = 0; |
|
1141 |
// else if (angle > 1.56 && angle < 1.58) |
|
1142 |
// degree = 90; |
|
1143 |
// else if (angle > 3.13 && angle < 3.15) |
|
1144 |
// degree = 180; |
|
1145 |
// else if (angle > 4.7 && angle < 4.72) |
|
1146 |
// degree = 270; |
|
1147 |
// else if (angle > 6.27 && angle < 6.29) |
|
1148 |
// degree = 0; |
|
1149 |
// else if (angle > -1.58 && angle < -1.56) |
|
1150 |
// degree = 270; |
|
1151 |
// else if (angle > -3.15 && angle < -3.13) |
|
1152 |
// degree = 180; |
|
1153 |
// else |
|
1154 |
// throw new Exception("Check Angle"); |
|
1155 |
|
|
1156 |
|
|
1157 |
// double originX, originY; |
|
1158 |
// symbol.GetOrigin(out originX, out originY); |
|
1159 |
|
|
1160 |
// double crossX = 0; |
|
1161 |
// double crossY = 0; |
|
1162 |
// double topX = 0; |
|
1163 |
// double topY = 0; |
|
1164 |
// foreach (var item in symbol.DrawingObjects) |
|
1165 |
// { |
|
1166 |
// Line2d line2d = item as Line2d; |
|
1167 |
// if (line2d != null) |
|
1168 |
// { |
|
1169 |
// double x1, y1, x2, y2; |
|
1170 |
// line2d.GetStartPoint(out x1, out y1); |
|
1171 |
// line2d.GetEndPoint(out x2, out y2); |
|
1172 |
// SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1); |
|
1173 |
|
|
1174 |
// if (slopeType == SlopeType.HORIZONTAL) |
|
1175 |
// { |
|
1176 |
// if (crossY == 0) |
|
1177 |
// crossY = y1; |
|
1178 |
// else |
|
1179 |
// crossY = (crossY + y1) / 2; |
|
1180 |
|
|
1181 |
// switch (degree) |
|
1182 |
// { |
|
1183 |
// case 90: |
|
1184 |
// if (topX == 0) |
|
1185 |
// topX = Math.Min(x1, x2); |
|
1186 |
// else |
|
1187 |
// topX = Math.Min(topX, Math.Min(x1, x2)); |
|
1188 |
// break; |
|
1189 |
// case 270: |
|
1190 |
// if (topX == 0) |
|
1191 |
// topX = Math.Max(x1, x2); |
|
1192 |
// else |
|
1193 |
// topX = Math.Max(topX, Math.Max(x1, x2)); |
|
1194 |
// break; |
|
1195 |
// default: |
|
1196 |
// break; |
|
1197 |
// } |
|
1198 |
// } |
|
1199 |
// else if (slopeType == SlopeType.VERTICAL) |
|
1200 |
// { |
|
1201 |
// if (crossX == 0) |
|
1202 |
// crossX = x1; |
|
1203 |
// else |
|
1204 |
// crossX = (crossX + x1) / 2; |
|
1205 |
|
|
1206 |
// switch (degree) |
|
1207 |
// { |
|
1208 |
// case 0: |
|
1209 |
// if (topY == 0) |
|
1210 |
// topY = Math.Max(y1, y2); |
|
1211 |
// else |
|
1212 |
// topY = Math.Max(topY, Math.Max(y1, y2)); |
|
1213 |
// break; |
|
1214 |
// case 180: |
|
1215 |
// if (topY == 0) |
|
1216 |
// topY = Math.Min(y1, y2); |
|
1217 |
// else |
|
1218 |
// topY = Math.Min(topY, Math.Min(y1, y2)); |
|
1219 |
// break; |
|
1220 |
// default: |
|
1221 |
// break; |
|
1222 |
// } |
|
1223 |
// } |
|
1224 |
// } |
|
1225 |
// } |
|
1226 |
// switch (degree) |
|
1227 |
// { |
|
1228 |
// case 0: |
|
1229 |
// crossX = originX; |
|
1230 |
// topX = crossX; |
|
1231 |
// break; |
|
1232 |
// case 90: |
|
1233 |
// crossY = originY; |
|
1234 |
// topY = crossY; |
|
1235 |
// break; |
|
1236 |
// case 180: |
|
1237 |
// crossX = originX; |
|
1238 |
// topX = crossX; |
|
1239 |
// break; |
|
1240 |
// case 270: |
|
1241 |
// crossY = originY; |
|
1242 |
// topY = crossY; |
|
1243 |
// break; |
|
1244 |
// default: |
|
1245 |
// break; |
|
1246 |
// } |
|
1247 |
|
|
1248 |
// SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3); |
|
1249 |
// SetSpecBreakParameters(symbol, dependency1, dependency2, degree); |
|
1250 |
// } |
|
1251 |
// else |
|
1252 |
// { |
|
1253 |
// MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1254 |
// } |
|
1255 |
//} |
|
1256 | 1098 |
private void btnSpecBreakRelocation_Click(object sender, EventArgs e) |
1257 | 1099 |
{ |
1258 | 1100 |
dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application"); |
1259 | 1101 |
WrapperApplication wApp = new WrapperApplication(dApplication.Application); |
1260 | 1102 |
application = wApp.RADApplication; |
1261 | 1103 |
|
1262 |
Ingr.RAD2D.SmartFrame2d borderFrame = application.ActiveDocument.ActiveSheet.SmartFrames2d[0]; |
|
1263 |
string styleName = borderFrame.Style.Name; |
|
1264 |
// |
|
1265 |
foreach (var item in application.ActiveDocument.SmartFrame2dStyles) |
|
1104 |
int count = application.ActiveSelectSet.Count; |
|
1105 |
int dependencyCount = 0; |
|
1106 |
foreach (var item in application.ActiveSelectSet) |
|
1107 |
if (item.GetType() == typeof(DependencyObject)) |
|
1108 |
dependencyCount++; |
|
1109 |
|
|
1110 |
if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject)) |
|
1266 | 1111 |
{ |
1267 |
string dd = item.Name; |
|
1112 |
MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1113 |
return; |
|
1268 | 1114 |
} |
1269 |
foreach (var item in application.ActiveDocument.ActiveSheet.SmartFrames2d) |
|
1115 |
|
|
1116 |
if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) && |
|
1117 |
(dependencyCount == 2 || dependencyCount == 3)) |
|
1118 |
{ |
|
1119 |
Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d; |
|
1120 |
|
|
1121 |
if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\")) |
|
1122 |
{ |
|
1123 |
MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1124 |
return; |
|
1125 |
} |
|
1126 |
|
|
1127 |
DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject; |
|
1128 |
DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject; |
|
1129 |
DependencyObject dependency3 = null; |
|
1130 |
if (count == 4) |
|
1131 |
dependency3 = application.ActiveSelectSet[3] as DependencyObject; |
|
1132 |
|
|
1133 |
application.ActiveSelectSet.RemoveAll(); |
|
1134 |
double angle = symbol.Angle; |
|
1135 |
if (symbol.GetTransform().HasReflection) |
|
1136 |
angle += Math.PI; |
|
1137 |
|
|
1138 |
double degree = double.NaN; |
|
1139 |
if (angle > -0.1 && angle < 0.1) |
|
1140 |
degree = 0; |
|
1141 |
else if (angle > 1.56 && angle < 1.58) |
|
1142 |
degree = 90; |
|
1143 |
else if (angle > 3.13 && angle < 3.15) |
|
1144 |
degree = 180; |
|
1145 |
else if (angle > 4.7 && angle < 4.72) |
|
1146 |
degree = 270; |
|
1147 |
else if (angle > 6.27 && angle < 6.29) |
|
1148 |
degree = 0; |
|
1149 |
else if (angle > -1.58 && angle < -1.56) |
|
1150 |
degree = 270; |
|
1151 |
else if (angle > -3.15 && angle < -3.13) |
|
1152 |
degree = 180; |
|
1153 |
else |
|
1154 |
throw new Exception("Check Angle"); |
|
1155 |
|
|
1156 |
|
|
1157 |
double originX, originY; |
|
1158 |
symbol.GetOrigin(out originX, out originY); |
|
1159 |
|
|
1160 |
double crossX = 0; |
|
1161 |
double crossY = 0; |
|
1162 |
double topX = 0; |
|
1163 |
double topY = 0; |
|
1164 |
foreach (var item in symbol.DrawingObjects) |
|
1165 |
{ |
|
1166 |
Line2d line2d = item as Line2d; |
|
1167 |
if (line2d != null) |
|
1168 |
{ |
|
1169 |
double x1, y1, x2, y2; |
|
1170 |
line2d.GetStartPoint(out x1, out y1); |
|
1171 |
line2d.GetEndPoint(out x2, out y2); |
|
1172 |
SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1); |
|
1173 |
|
|
1174 |
if (slopeType == SlopeType.HORIZONTAL) |
|
1175 |
{ |
|
1176 |
if (crossY == 0) |
|
1177 |
crossY = y1; |
|
1178 |
else |
|
1179 |
crossY = (crossY + y1) / 2; |
|
1180 |
|
|
1181 |
switch (degree) |
|
1182 |
{ |
|
1183 |
case 90: |
|
1184 |
if (topX == 0) |
|
1185 |
topX = Math.Min(x1, x2); |
|
1186 |
else |
|
1187 |
topX = Math.Min(topX, Math.Min(x1, x2)); |
|
1188 |
break; |
|
1189 |
case 270: |
|
1190 |
if (topX == 0) |
|
1191 |
topX = Math.Max(x1, x2); |
|
1192 |
else |
|
1193 |
topX = Math.Max(topX, Math.Max(x1, x2)); |
|
1194 |
break; |
|
1195 |
default: |
|
1196 |
break; |
|
1197 |
} |
|
1198 |
} |
|
1199 |
else if (slopeType == SlopeType.VERTICAL) |
|
1200 |
{ |
|
1201 |
if (crossX == 0) |
|
1202 |
crossX = x1; |
|
1203 |
else |
|
1204 |
crossX = (crossX + x1) / 2; |
|
1205 |
|
|
1206 |
switch (degree) |
|
1207 |
{ |
|
1208 |
case 0: |
|
1209 |
if (topY == 0) |
|
1210 |
topY = Math.Max(y1, y2); |
|
1211 |
else |
|
1212 |
topY = Math.Max(topY, Math.Max(y1, y2)); |
|
1213 |
break; |
|
1214 |
case 180: |
|
1215 |
if (topY == 0) |
|
1216 |
topY = Math.Min(y1, y2); |
|
1217 |
else |
|
1218 |
topY = Math.Min(topY, Math.Min(y1, y2)); |
|
1219 |
break; |
|
1220 |
default: |
|
1221 |
break; |
|
1222 |
} |
|
1223 |
} |
|
1224 |
} |
|
1225 |
} |
|
1226 |
switch (degree) |
|
1227 |
{ |
|
1228 |
case 0: |
|
1229 |
crossX = originX; |
|
1230 |
topX = crossX; |
|
1231 |
break; |
|
1232 |
case 90: |
|
1233 |
crossY = originY; |
|
1234 |
topY = crossY; |
|
1235 |
break; |
|
1236 |
case 180: |
|
1237 |
crossX = originX; |
|
1238 |
topX = crossX; |
|
1239 |
break; |
|
1240 |
case 270: |
|
1241 |
crossY = originY; |
|
1242 |
topY = crossY; |
|
1243 |
break; |
|
1244 |
default: |
|
1245 |
break; |
|
1246 |
} |
|
1247 |
|
|
1248 |
SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3); |
|
1249 |
SetSpecBreakParameters(symbol, dependency1, dependency2, degree); |
|
1250 |
} |
|
1251 |
else |
|
1270 | 1252 |
{ |
1271 |
var aa = item.Style;
|
|
1253 |
MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
1272 | 1254 |
} |
1273 | 1255 |
} |
1274 | 1256 |
private void SetSpecBreakParameters(Symbol2d symbol, DependencyObject dependency1, DependencyObject dependency2, double degree) |
내보내기 Unified diff