개정판 8c7fc81a
dev issue #507 : edit label
Change-Id: I1de9ea20aaa245ff6cccf5bac532f8880b7f8264
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
4322 | 4322 |
{ |
4323 | 4323 |
LMLabelPersist removeLabel = dataSource.GetLabelPersist(lineNumber.SPPID.RepresentationId); |
4324 | 4324 |
if (removeLabel != null) |
4325 |
{ |
|
4325 |
{
|
|
4326 | 4326 |
GridSetting gridSetting = GridSetting.GetInstance(); |
4327 | 4327 |
LMConnector connector = dataSource.GetConnector(removeLabel.RepresentationID); |
4328 | 4328 |
// |
... | ... | |
5307 | 5307 |
{ |
5308 | 5308 |
if (!string.IsNullOrEmpty(text.SPPID.RepresentationId)) |
5309 | 5309 |
{ |
5310 |
List<Text> texts = new List<Text>();
|
|
5310 |
List<Text> allTexts = new List<Text>();
|
|
5311 | 5311 |
LMLabelPersist targetLabel = dataSource.GetLabelPersist(text.SPPID.RepresentationId); |
5312 | 5312 |
LMRepresentation representation = targetLabel.RepresentationObject; |
5313 | 5313 |
Symbol symbol = document.SYMBOLS.Find(x => x.SPPID.RepresentationId == representation.Id); |
... | ... | |
5325 | 5325 |
double[] range = null; |
5326 | 5326 |
GetSPPIDSymbolRange(labelPersist, ref range); |
5327 | 5327 |
findText.SPPID.Range = range; |
5328 |
texts.Add(findText);
|
|
5328 |
allTexts.Add(findText);
|
|
5329 | 5329 |
} |
5330 | 5330 |
|
5331 | 5331 |
ReleaseCOMObjects(labelPersist); |
5332 | 5332 |
} |
5333 | 5333 |
|
5334 |
if (texts.Count > 0)
|
|
5334 |
if (allTexts.Count > 0)
|
|
5335 | 5335 |
{ |
5336 | 5336 |
#region Sort Text By Y |
5337 |
texts.Sort(SortTextByY);
|
|
5337 |
allTexts.Sort(SortTextByY);
|
|
5338 | 5338 |
int SortTextByY(Text a, Text b) |
5339 | 5339 |
{ |
5340 | 5340 |
return b.SPPID.Range[3].CompareTo(a.SPPID.Range[3]); |
5341 | 5341 |
} |
5342 | 5342 |
#endregion |
5343 | 5343 |
|
5344 |
#region 첫번째 Text로 기준 맞춤 |
|
5345 |
for (int i = 0; i < texts.Count; i++) |
|
5344 |
#region 정렬하기전 방향 |
|
5345 |
List<Text> left = new List<Text>(); |
|
5346 |
List<Text> down = new List<Text>(); |
|
5347 |
List<Text> right = new List<Text>(); |
|
5348 |
List<Text> up = new List<Text>(); |
|
5349 |
List<List<Text>> sortTexts = new List<List<Text>>() { left, down, right, up }; |
|
5350 |
foreach (var loopText in allTexts) |
|
5346 | 5351 |
{ |
5347 |
if (i != 0) |
|
5352 |
double textCenterX = (loopText.X1 + loopText.X2) / 2; |
|
5353 |
double textCenterY = (loopText.Y1 + loopText.Y2) / 2; |
|
5354 |
double originX = 0; |
|
5355 |
double originY = 0; |
|
5356 |
SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref originX, ref originY); |
|
5357 |
double angle = SPPIDUtil.CalcAngle(textCenterX, textCenterY, originX, originY); |
|
5358 |
|
|
5359 |
if (angle < 45) |
|
5360 |
{ |
|
5361 |
// Text 오른쪽 |
|
5362 |
if (textCenterX > originX) |
|
5363 |
right.Add(loopText); |
|
5364 |
// Text 왼쪽 |
|
5365 |
else |
|
5366 |
left.Add(loopText); |
|
5367 |
} |
|
5368 |
else |
|
5348 | 5369 |
{ |
5349 |
Text currentText = texts[i]; |
|
5350 |
Text prevText = texts[i - 1]; |
|
5351 |
double minY = prevText.SPPID.Range[1]; |
|
5352 |
double centerPrevX = (prevText.SPPID.Range[0] + prevText.SPPID.Range[2]) / 2; |
|
5353 |
double centerX = (currentText.SPPID.Range[0] + currentText.SPPID.Range[2]) / 2; |
|
5354 |
double _gapX = centerX - centerPrevX; |
|
5355 |
double _gapY = currentText.SPPID.Range[3] - minY; |
|
5356 |
MoveText(currentText, _gapX, _gapY); |
|
5370 |
// Text 아래쪽 |
|
5371 |
if (textCenterY > originY) |
|
5372 |
down.Add(loopText); |
|
5373 |
// Text 위쪽 |
|
5374 |
else |
|
5375 |
up.Add(loopText); |
|
5357 | 5376 |
} |
5358 | 5377 |
} |
5359 |
List<double> rangeMinX = texts.Select(loopX => loopX.SPPID.Range[0]).ToList(); |
|
5360 |
List<double> rangeMinY = texts.Select(loopX => loopX.SPPID.Range[1]).ToList(); |
|
5361 |
List<double> rangeMaxX = texts.Select(loopX => loopX.SPPID.Range[2]).ToList(); |
|
5362 |
List<double> rangeMaxY = texts.Select(loopX => loopX.SPPID.Range[3]).ToList(); |
|
5363 |
rangeMinX.Sort(); |
|
5364 |
rangeMinY.Sort(); |
|
5365 |
rangeMaxX.Sort(); |
|
5366 |
rangeMaxY.Sort(); |
|
5367 |
double allTextCenterX = (rangeMinX[0] + rangeMaxX[rangeMaxX.Count - 1]) / 2; |
|
5368 |
double allTextCenterY = (rangeMinY[0] + rangeMaxY[rangeMaxY.Count - 1]) / 2; |
|
5378 |
|
|
5369 | 5379 |
#endregion |
5370 | 5380 |
|
5371 |
Text correctBySymbol = texts[0]; |
|
5372 |
double textCenterX = (text.X1 + text.X2) / 2; |
|
5373 |
double textCenterY = (text.Y1 + text.Y2) / 2; |
|
5374 |
double originX = 0; |
|
5375 |
double originY = 0; |
|
5376 |
SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref originX, ref originY); |
|
5377 |
double angle = SPPIDUtil.CalcAngle(textCenterX, textCenterY, originX, originY); |
|
5378 |
double symbolCenterX = (symbolRange[0] + symbolRange[2]) / 2; |
|
5379 |
double symbolCenterY = (symbolRange[1] + symbolRange[3]) / 2; |
|
5380 |
|
|
5381 |
double gapX = 0; |
|
5382 |
double gapY = 0; |
|
5383 |
if (angle < 45) |
|
5381 |
foreach (var texts in sortTexts) |
|
5384 | 5382 |
{ |
5385 |
// Text 오른쪽 |
|
5386 |
if (textCenterX > originX) |
|
5383 |
if (texts.Count == 0 ) |
|
5384 |
continue; |
|
5385 |
|
|
5386 |
#region 첫번째 Text로 기준 맞춤 |
|
5387 |
for (int i = 0; i < texts.Count; i++) |
|
5387 | 5388 |
{ |
5388 |
gapX = rangeMinX[0] - symbolRange[2]; |
|
5389 |
gapY = allTextCenterY - symbolCenterY; |
|
5390 |
} |
|
5391 |
// Text 왼쪽 |
|
5392 |
else |
|
5393 |
{ |
|
5394 |
gapX = rangeMaxX[rangeMaxX.Count - 1] - symbolRange[0]; |
|
5395 |
gapY = allTextCenterY - symbolCenterY; |
|
5389 |
if (i != 0) |
|
5390 |
{ |
|
5391 |
Text currentText = texts[i]; |
|
5392 |
Text prevText = texts[i - 1]; |
|
5393 |
double minY = prevText.SPPID.Range[1]; |
|
5394 |
double centerPrevX = (prevText.SPPID.Range[0] + prevText.SPPID.Range[2]) / 2; |
|
5395 |
double centerX = (currentText.SPPID.Range[0] + currentText.SPPID.Range[2]) / 2; |
|
5396 |
double _gapX = centerX - centerPrevX; |
|
5397 |
double _gapY = currentText.SPPID.Range[3] - minY; |
|
5398 |
MoveText(currentText, _gapX, _gapY); |
|
5399 |
} |
|
5396 | 5400 |
} |
5397 |
} |
|
5398 |
else |
|
5399 |
{ |
|
5400 |
// Text 아래쪽 |
|
5401 |
if (textCenterY > originY) |
|
5401 |
List<double> rangeMinX = texts.Select(loopX => loopX.SPPID.Range[0]).ToList(); |
|
5402 |
List<double> rangeMinY = texts.Select(loopX => loopX.SPPID.Range[1]).ToList(); |
|
5403 |
List<double> rangeMaxX = texts.Select(loopX => loopX.SPPID.Range[2]).ToList(); |
|
5404 |
List<double> rangeMaxY = texts.Select(loopX => loopX.SPPID.Range[3]).ToList(); |
|
5405 |
rangeMinX.Sort(); |
|
5406 |
rangeMinY.Sort(); |
|
5407 |
rangeMaxX.Sort(); |
|
5408 |
rangeMaxY.Sort(); |
|
5409 |
double allTextCenterX = (rangeMinX[0] + rangeMaxX[rangeMaxX.Count - 1]) / 2; |
|
5410 |
double allTextCenterY = (rangeMinY[0] + rangeMaxY[rangeMaxY.Count - 1]) / 2; |
|
5411 |
#endregion |
|
5412 |
#region 정렬 |
|
5413 |
Text correctBySymbol = texts[0]; |
|
5414 |
double textCenterX = (correctBySymbol.X1 + correctBySymbol.X2) / 2; |
|
5415 |
double textCenterY = (correctBySymbol.Y1 + correctBySymbol.Y2) / 2; |
|
5416 |
double originX = 0; |
|
5417 |
double originY = 0; |
|
5418 |
SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref originX, ref originY); |
|
5419 |
double angle = SPPIDUtil.CalcAngle(textCenterX, textCenterY, originX, originY); |
|
5420 |
double symbolCenterX = (symbolRange[0] + symbolRange[2]) / 2; |
|
5421 |
double symbolCenterY = (symbolRange[1] + symbolRange[3]) / 2; |
|
5422 |
|
|
5423 |
double gapX = 0; |
|
5424 |
double gapY = 0; |
|
5425 |
if (angle < 45) |
|
5402 | 5426 |
{ |
5403 |
gapX = allTextCenterX - symbolCenterX; |
|
5404 |
gapY = rangeMaxY[rangeMaxY.Count - 1] - symbolRange[1]; |
|
5427 |
// Text 오른쪽 |
|
5428 |
if (textCenterX > originX) |
|
5429 |
{ |
|
5430 |
gapX = rangeMinX[0] - symbolRange[2]; |
|
5431 |
gapY = allTextCenterY - symbolCenterY; |
|
5432 |
} |
|
5433 |
// Text 왼쪽 |
|
5434 |
else |
|
5435 |
{ |
|
5436 |
gapX = rangeMaxX[rangeMaxX.Count - 1] - symbolRange[0]; |
|
5437 |
gapY = allTextCenterY - symbolCenterY; |
|
5438 |
} |
|
5405 | 5439 |
} |
5406 |
// Text 위쪽 |
|
5407 | 5440 |
else |
5408 | 5441 |
{ |
5409 |
gapX = allTextCenterX - symbolCenterX; |
|
5410 |
gapY = rangeMinY[0] - symbolRange[3]; |
|
5442 |
// Text 아래쪽 |
|
5443 |
if (textCenterY > originY) |
|
5444 |
{ |
|
5445 |
gapX = allTextCenterX - symbolCenterX; |
|
5446 |
gapY = rangeMaxY[rangeMaxY.Count - 1] - symbolRange[1]; |
|
5447 |
} |
|
5448 |
// Text 위쪽 |
|
5449 |
else |
|
5450 |
{ |
|
5451 |
gapX = allTextCenterX - symbolCenterX; |
|
5452 |
gapY = rangeMinY[0] - symbolRange[3]; |
|
5453 |
} |
|
5411 | 5454 |
} |
5412 |
} |
|
5413 | 5455 |
|
5414 |
foreach (var item in texts) |
|
5415 |
{ |
|
5416 |
MoveText(item, gapX, gapY); |
|
5417 |
RemodelingAssociationText(item); |
|
5456 |
foreach (var item in texts) |
|
5457 |
{ |
|
5458 |
MoveText(item, gapX, gapY); |
|
5459 |
RemodelingAssociationText(item); |
|
5460 |
} |
|
5461 |
#endregion |
|
5418 | 5462 |
} |
5419 | 5463 |
} |
5420 | 5464 |
} |
... | ... | |
5432 | 5476 |
}; |
5433 | 5477 |
} |
5434 | 5478 |
|
5435 |
endTexts.AddRange(texts);
|
|
5479 |
endTexts.AddRange(allTexts);
|
|
5436 | 5480 |
|
5437 | 5481 |
ReleaseCOMObjects(targetLabel); |
5438 | 5482 |
targetLabel = null; |
내보내기 Unified diff