개정판 e27329d6
dev issue #507 : Text 보정 기준을 ID2로 변경
Change-Id: I47c2b2b848a14f94d988e25af86a29c2daf065f0
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
804 | 804 |
{ |
805 | 805 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.TEXTINFOS.Count); |
806 | 806 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Texts Modeling"); |
807 |
List<Text> correctList = new List<Text>();
|
|
807 |
SortText(document.TEXTINFOS);
|
|
808 | 808 |
foreach (var item in document.TEXTINFOS) |
809 | 809 |
try |
810 | 810 |
{ |
811 |
TextModeling(item, correctList); |
|
812 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
|
813 |
} |
|
814 |
catch (Exception ex) |
|
815 |
{ |
|
816 |
Log.Write("Error in TextModeling"); |
|
817 |
Log.Write("UID : " + item.UID); |
|
818 |
Log.Write(ex.Message); |
|
819 |
Log.Write(ex.StackTrace); |
|
820 |
} |
|
821 |
|
|
822 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, correctList.Count); |
|
823 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Correct Text"); |
|
824 |
SortText(correctList); |
|
825 |
List<Text> endList = new List<Text>(); |
|
826 |
if (correctList.Count > 0) |
|
827 |
endList.Add(correctList[0]); |
|
828 |
foreach (var item in correctList) |
|
829 |
try |
|
830 |
{ |
|
831 |
if (!endList.Contains(item)) |
|
832 |
TextCorrectModeling(item, endList); |
|
811 |
if (item.ASSOCIATION) |
|
812 |
AssociationTextModeling(item); |
|
813 |
else |
|
814 |
NormalTextModeling(item); |
|
833 | 815 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
834 | 816 |
} |
835 | 817 |
catch (Exception ex) |
... | ... | |
4373 | 4355 |
/// Text Modeling - Association일 경우는 Text대신 해당 맵핑된 Symbol로 모델링 |
4374 | 4356 |
/// </summary> |
4375 | 4357 |
/// <param name="text"></param> |
4376 |
private void TextModeling(Text text, List<Text> correctList)
|
|
4358 |
private void NormalTextModeling(Text text)
|
|
4377 | 4359 |
{ |
4378 | 4360 |
LMSymbol _LMSymbol = null; |
4379 |
LMConnector connectedLMConnector = null; |
|
4380 |
//if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
|
4381 |
if (text.ASSOCIATION) |
|
4361 |
|
|
4362 |
LMItemNote _LMItemNote = null; |
|
4363 |
LMAAttribute _LMAAttribute = null; |
|
4364 |
|
|
4365 |
double x = 0; |
|
4366 |
double y = 0; |
|
4367 |
double angle = text.ANGLE; |
|
4368 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
|
4369 |
|
|
4370 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
4371 |
text.SPPID.SPPID_X = x; |
|
4372 |
text.SPPID.SPPID_Y = y; |
|
4373 |
|
|
4374 |
_LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y, Rotation: angle); |
|
4375 |
if (_LMSymbol != null) |
|
4382 | 4376 |
{ |
4383 |
object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
|
4384 |
if (owner != null && owner.GetType() == typeof(Symbol)) |
|
4377 |
_LMSymbol.Commit(); |
|
4378 |
_LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
|
4379 |
if (_LMItemNote != null) |
|
4385 | 4380 |
{ |
4386 |
Symbol symbol = owner as Symbol;
|
|
4387 |
_LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId);
|
|
4388 |
if (_LMSymbol != null)
|
|
4381 |
_LMItemNote.Commit();
|
|
4382 |
_LMAAttribute = _LMItemNote.Attributes["Note.Body"];
|
|
4383 |
if (_LMAAttribute != null)
|
|
4389 | 4384 |
{ |
4390 |
BaseModel.Attribute attribute = symbol.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
|
4391 |
if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
|
4392 |
{ |
|
4393 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
|
4385 |
_LMAAttribute.set_Value(text.VALUE); |
|
4386 |
text.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
|
4387 |
_LMItemNote.Commit(); |
|
4394 | 4388 |
|
4395 |
if (mapping != null) |
|
4396 |
{ |
|
4397 |
double x = 0; |
|
4398 |
double y = 0; |
|
4399 | 4389 |
|
4400 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
|
4401 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
4402 |
Array array = new double[] { 0, x, y }; |
|
4403 |
text.SPPID.SPPID_X = x; |
|
4404 |
text.SPPID.SPPID_Y = y; |
|
4405 |
LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
|
4406 |
if (_LMLabelPersist != null) |
|
4390 |
double[] range = null; |
|
4391 |
foreach (LMLabelPersist labelPersist in _LMSymbol.LabelPersists) |
|
4392 |
{ |
|
4393 |
double[] temp = null; |
|
4394 |
GetSPPIDSymbolRange(labelPersist, ref temp); |
|
4395 |
if (temp != null) |
|
4396 |
{ |
|
4397 |
if (range == null) |
|
4398 |
range = temp; |
|
4399 |
else |
|
4407 | 4400 |
{ |
4408 |
text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
|
4409 |
_LMLabelPersist.Commit(); |
|
4410 |
ReleaseCOMObjects(_LMLabelPersist); |
|
4401 |
range = new double[] { |
|
4402 |
Math.Min(range[0], temp[0]), |
|
4403 |
Math.Min(range[1], temp[1]), |
|
4404 |
Math.Max(range[2], temp[2]), |
|
4405 |
Math.Max(range[3], temp[3]) |
|
4406 |
}; |
|
4411 | 4407 |
} |
4412 | 4408 |
} |
4413 | 4409 |
} |
4410 |
text.SPPID.Range = range; |
|
4411 |
|
|
4412 |
if (_LMAAttribute != null) |
|
4413 |
ReleaseCOMObjects(_LMAAttribute); |
|
4414 |
if (_LMItemNote != null) |
|
4415 |
ReleaseCOMObjects(_LMItemNote); |
|
4414 | 4416 |
} |
4417 |
|
|
4418 |
TextCorrectModeling(text); |
|
4415 | 4419 |
} |
4416 |
else if (owner != null && owner.GetType() == typeof(Line)) |
|
4417 |
{ |
|
4418 |
Line line = owner as Line; |
|
4419 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
|
4420 |
connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y); |
|
4420 |
} |
|
4421 |
if (_LMSymbol != null) |
|
4422 |
ReleaseCOMObjects(_LMSymbol); |
|
4423 |
} |
|
4421 | 4424 |
|
4422 |
if (connectedLMConnector != null) |
|
4425 |
private void AssociationTextModeling(Text text) |
|
4426 |
{ |
|
4427 |
LMSymbol _LMSymbol = null; |
|
4428 |
LMConnector connectedLMConnector = null; |
|
4429 |
object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
|
4430 |
if (owner != null && owner.GetType() == typeof(Symbol)) |
|
4431 |
{ |
|
4432 |
Symbol symbol = owner as Symbol; |
|
4433 |
_LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
|
4434 |
if (_LMSymbol != null) |
|
4435 |
{ |
|
4436 |
BaseModel.Attribute attribute = symbol.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
|
4437 |
if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
|
4423 | 4438 |
{ |
4424 |
BaseModel.Attribute attribute = line.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
|
4425 |
if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
|
4439 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
|
4440 |
|
|
4441 |
if (mapping != null) |
|
4426 | 4442 |
{ |
4427 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
|
4443 |
double x = 0; |
|
4444 |
double y = 0; |
|
4428 | 4445 |
|
4429 |
if (mapping != null) |
|
4446 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
|
4447 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
4448 |
Array array = new double[] { 0, x, y }; |
|
4449 |
text.SPPID.SPPID_X = x; |
|
4450 |
text.SPPID.SPPID_Y = y; |
|
4451 |
LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
|
4452 |
if (_LMLabelPersist != null) |
|
4430 | 4453 |
{ |
4431 |
double x = 0; |
|
4432 |
double y = 0; |
|
4433 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
|
4434 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
4435 |
Array array = new double[] { 0, x, y }; |
|
4436 |
|
|
4437 |
LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
|
4438 |
if (_LMLabelPersist != null) |
|
4439 |
{ |
|
4440 |
text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
|
4441 |
_LMLabelPersist.Commit(); |
|
4442 |
ReleaseCOMObjects(_LMLabelPersist); |
|
4443 |
} |
|
4454 |
text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
|
4455 |
_LMLabelPersist.Commit(); |
|
4456 |
ReleaseCOMObjects(_LMLabelPersist); |
|
4444 | 4457 |
} |
4445 | 4458 |
} |
4446 | 4459 |
} |
4447 | 4460 |
} |
4448 | 4461 |
} |
4449 |
else |
|
4462 |
else if (owner != null && owner.GetType() == typeof(Line))
|
|
4450 | 4463 |
{ |
4451 |
LMItemNote _LMItemNote = null; |
|
4452 |
LMAAttribute _LMAAttribute = null; |
|
4453 |
|
|
4454 |
double x = 0; |
|
4455 |
double y = 0; |
|
4456 |
double angle = text.ANGLE; |
|
4457 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
|
4458 |
|
|
4459 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
4460 |
text.SPPID.SPPID_X = x; |
|
4461 |
text.SPPID.SPPID_Y = y; |
|
4464 |
Line line = owner as Line; |
|
4465 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
|
4466 |
connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y); |
|
4462 | 4467 |
|
4463 |
_LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y, Rotation: angle); |
|
4464 |
if (_LMSymbol != null) |
|
4468 |
if (connectedLMConnector != null) |
|
4465 | 4469 |
{ |
4466 |
_LMSymbol.Commit(); |
|
4467 |
_LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
|
4468 |
if (_LMItemNote != null) |
|
4470 |
BaseModel.Attribute attribute = line.ATTRIBUTES.Find(x => x.ASSOCITEM == text.UID); |
|
4471 |
if (attribute != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None") |
|
4469 | 4472 |
{ |
4470 |
_LMItemNote.Commit(); |
|
4471 |
_LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
|
4472 |
if (_LMAAttribute != null) |
|
4473 |
{ |
|
4474 |
_LMAAttribute.set_Value(text.VALUE); |
|
4475 |
text.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
|
4476 |
_LMItemNote.Commit(); |
|
4473 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
|
4477 | 4474 |
|
4475 |
if (mapping != null) |
|
4476 |
{ |
|
4477 |
double x = 0; |
|
4478 |
double y = 0; |
|
4479 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
|
4480 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
|
4481 |
Array array = new double[] { 0, x, y }; |
|
4478 | 4482 |
|
4479 |
double[] range = null;
|
|
4480 |
foreach (LMLabelPersist labelPersist in _LMSymbol.LabelPersists)
|
|
4483 |
LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine);
|
|
4484 |
if (_LMLabelPersist != null)
|
|
4481 | 4485 |
{ |
4482 |
double[] temp = null; |
|
4483 |
GetSPPIDSymbolRange(labelPersist, ref temp); |
|
4484 |
if (temp != null) |
|
4485 |
{ |
|
4486 |
if (range == null) |
|
4487 |
range = temp; |
|
4488 |
else |
|
4489 |
{ |
|
4490 |
range = new double[] { |
|
4491 |
Math.Min(range[0], temp[0]), |
|
4492 |
Math.Min(range[1], temp[1]), |
|
4493 |
Math.Max(range[2], temp[2]), |
|
4494 |
Math.Max(range[3], temp[3]) |
|
4495 |
}; |
|
4496 |
} |
|
4497 |
} |
|
4486 |
text.SPPID.RepresentationId = _LMLabelPersist.AsLMRepresentation().Id; |
|
4487 |
_LMLabelPersist.Commit(); |
|
4488 |
ReleaseCOMObjects(_LMLabelPersist); |
|
4498 | 4489 |
} |
4499 |
if (range != null) |
|
4500 |
correctList.Add(text); |
|
4501 |
text.SPPID.Range = range; |
|
4502 |
|
|
4503 |
|
|
4504 |
if (_LMAAttribute != null) |
|
4505 |
ReleaseCOMObjects(_LMAAttribute); |
|
4506 |
if (_LMItemNote != null) |
|
4507 |
ReleaseCOMObjects(_LMItemNote); |
|
4508 | 4490 |
} |
4509 | 4491 |
} |
4510 | 4492 |
} |
... | ... | |
4513 | 4495 |
ReleaseCOMObjects(_LMSymbol); |
4514 | 4496 |
} |
4515 | 4497 |
|
4516 |
private void TextCorrectModeling(Text text, List<Text> endList)
|
|
4498 |
private void TextCorrectModeling(Text text) |
|
4517 | 4499 |
{ |
4500 |
if (text.SPPID.Range == null) |
|
4501 |
return; |
|
4502 |
|
|
4518 | 4503 |
bool needRemodeling = false; |
4519 | 4504 |
bool loop = true; |
4520 | 4505 |
GridSetting gridSetting = GridSetting.GetInstance(); |
4521 | 4506 |
while (loop) |
4522 | 4507 |
{ |
4523 | 4508 |
loop = false; |
4524 |
foreach (var overlapText in endList)
|
|
4509 |
foreach (var overlapText in document.TEXTINFOS)
|
|
4525 | 4510 |
{ |
4511 |
if (overlapText.ASSOCIATION || overlapText == text || overlapText.SPPID.Range == null) |
|
4512 |
continue; |
|
4513 |
|
|
4526 | 4514 |
if (SPPIDUtil.IsOverlap(overlapText.SPPID.Range, text.SPPID.Range)) |
4527 | 4515 |
{ |
4516 |
double percentX = 0; |
|
4517 |
double percentY = 0; |
|
4518 |
if (overlapText.X1 <= text.X2 && overlapText.X2 >= text.X1) |
|
4519 |
{ |
|
4520 |
double gapX = Math.Min(overlapText.X2, text.X2) - Math.Max(overlapText.X1, text.X1); |
|
4521 |
percentX = Math.Max(gapX / (overlapText.X2 - overlapText.X1), gapX / (text.X2 - text.X1)); |
|
4522 |
} |
|
4523 |
if (overlapText.Y1 <= text.Y2 && overlapText.Y2 >= text.Y1) |
|
4524 |
{ |
|
4525 |
double gapY = Math.Min(overlapText.Y2, text.Y2) - Math.Max(overlapText.Y1, text.Y1); |
|
4526 |
percentY = Math.Max(gapY / (overlapText.Y2 - overlapText.Y1), gapY / (text.Y2 - text.Y1)); |
|
4527 |
} |
|
4528 |
|
|
4528 | 4529 |
double tempX = 0; |
4529 | 4530 |
double tempY = 0; |
4530 | 4531 |
bool overlapX = false; |
4531 | 4532 |
bool overlapY = false; |
4532 | 4533 |
SPPIDUtil.CalcOverlap(text.SPPID.Range, overlapText.SPPID.Range, ref tempX, ref tempY, ref overlapX, ref overlapY); |
4533 |
double angle = SPPIDUtil.CalcAngle(text.LOCATION_X, text.LOCATION_Y, overlapText.LOCATION_X, overlapText.LOCATION_Y); |
|
4534 |
if (overlapY && angle >= 45) |
|
4534 |
if (percentX >= percentY) |
|
4535 | 4535 |
{ |
4536 | 4536 |
int count = Convert.ToInt32(tempY / gridSetting.Length) + 1; |
4537 | 4537 |
double move = gridSetting.Length * count; |
... | ... | |
4540 | 4540 |
needRemodeling = true; |
4541 | 4541 |
loop = true; |
4542 | 4542 |
} |
4543 |
if (overlapX && angle <= 45)
|
|
4543 |
else
|
|
4544 | 4544 |
{ |
4545 | 4545 |
int count = Convert.ToInt32(tempX / gridSetting.Length) + 1; |
4546 | 4546 |
double move = gridSetting.Length * count; |
... | ... | |
4592 | 4592 |
ReleaseCOMObjects(_LMSymbol); |
4593 | 4593 |
_LMSymbol = null; |
4594 | 4594 |
} |
4595 |
|
|
4596 |
endList.Add(text); |
|
4597 | 4595 |
} |
4598 | 4596 |
|
4599 | 4597 |
private void AssociationTextCorrectModeling(Text text, List<Text> endTexts) |
내보내기 Unified diff