개정판 f1632ad7
issue #578: add condition to connect and 000 now symbol connected near symbol
Change-Id: I2d454d150ddc646a5cb49493b5da4282381370c0
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
466 | 466 |
@date 18.11.02 |
467 | 467 |
""" |
468 | 468 |
appDocData = AppDocData.instance() |
469 |
drawing = os.path.join(appDocData.getCurrentProject().getDrawingFilePath(), item.text(column))
|
|
469 |
drawing = os.path.join(appDocData.getCurrentProject().getDrawingFilePath(), item.text(0))
|
|
470 | 470 |
self.onOpenImageDrawing(drawing) |
471 | 471 |
|
472 | 472 |
def onShowDetectSymbol(self): |
DTI_PID/DTI_PID/RecognitionDialog.py | ||
---|---|---|
474 | 474 |
configs = appDocData.getConfigs('Line Detector', 'Length to connect line') |
475 | 475 |
toler = int(configs[0].value) if configs else 20 |
476 | 476 |
if appDocData.lines: |
477 |
# connect line to symbol |
|
478 |
try: |
|
479 |
for line in appDocData.lines: |
|
480 |
matches = [symbol for symbol in symbols if symbol.is_connectable(line, toler=toler)] |
|
481 |
for symbol in matches: |
|
482 |
detector.connectLineToSymbol(line, symbol, toler=5) |
|
483 |
except Exception as ex: |
|
484 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
485 |
worker.displayLog.emit(MessageType.Error, message) |
|
486 |
# up to here |
|
487 |
|
|
488 | 477 |
# connect line to line |
489 | 478 |
configs = appDocData.getConfigs('Line Detector', 'Length to connect line') |
490 | 479 |
toler = int(configs[0].value) if configs else 20 |
... | ... | |
507 | 496 |
worker.displayLog.emit(MessageType.Error, message) |
508 | 497 |
# up to here |
509 | 498 |
|
499 |
# connect line to symbol |
|
500 |
try: |
|
501 |
for line in appDocData.lines: |
|
502 |
matches = [symbol for symbol in symbols if symbol.is_connectable(line, toler=toler)] |
|
503 |
for symbol in matches: |
|
504 |
detector.connectLineToSymbol(line, symbol, toler=5) |
|
505 |
except Exception as ex: |
|
506 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
507 |
worker.displayLog.emit(MessageType.Error, message) |
|
508 |
# up to here |
|
509 |
|
|
510 |
# connect symbol to symbol |
|
511 |
try: |
|
512 |
for symbol in appDocData.symbols: |
|
513 |
matches = [it for it in appDocData.symbols if it is not symbol and symbol.is_connectable(it)] |
|
514 |
#print(str(symbol)) |
|
515 |
#print(matches) |
|
516 |
for match in matches: |
|
517 |
symbol.connect_if_possible(match) |
|
518 |
except Exception as ex: |
|
519 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
520 |
worker.displayLog.emit(MessageType.Error, message) |
|
521 |
# up to here |
|
522 |
|
|
510 | 523 |
createUnknownItems(mainRes) |
511 | 524 |
|
512 | 525 |
worker.updateBatchProgress.emit(len(srcList), 1) |
DTI_PID/DTI_PID/Shapes/EngineeringReservedWordTextItem.py | ||
---|---|---|
87 | 87 |
|
88 | 88 |
minDist = 30 |
89 | 89 |
for line in lines: |
90 |
if line.connectors[1].connectedItem is not None: continue |
|
91 |
|
|
90 | 92 |
dl = min(self.sceneBoundingRect().height(), self.sceneBoundingRect().width()) / 10 |
91 | 93 |
dx = dl if (line.connectors[0].sceneConnectPoint[0] - line.connectors[1].sceneConnectPoint[0]) > 0 else -dl |
92 | 94 |
dy = -dl if (line.connectors[0].sceneConnectPoint[1] - line.connectors[1].sceneConnectPoint[1]) > 0 else dl |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
442 | 442 |
@author humkyung |
443 | 443 |
@date 2018.04.13 |
444 | 444 |
''' |
445 |
def is_connectable(self, line, toler=10): |
|
446 |
start_pt = line.startPoint() |
|
447 |
end_pt = line.endPoint() |
|
445 |
def is_connectable(self, item, toler=10): |
|
446 |
#from EngineeringLineItem import QEngineeringLineItem |
|
447 |
|
|
448 |
''' |
|
449 |
if False:#type(item) is QEngineeringLineItem: |
|
450 |
line = item |
|
451 |
start_pt = line.startPoint() |
|
452 |
end_pt = line.endPoint() |
|
453 |
for connector in self.connectors: |
|
454 |
dx = connector.sceneConnectPoint[0] - (start_pt[0]) |
|
455 |
dy = connector.sceneConnectPoint[1] - (start_pt[1]) |
|
456 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True |
|
457 |
dx = connector.sceneConnectPoint[0] - (end_pt[0]) |
|
458 |
dy = connector.sceneConnectPoint[1] - (end_pt[1]) |
|
459 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True |
|
460 |
elif True:#issubclass(type(item), SymbolSvgItem): |
|
461 |
''' |
|
448 | 462 |
for connector in self.connectors: |
449 |
dx = connector.sceneConnectPoint[0] - (start_pt[0]) |
|
450 |
dy = connector.sceneConnectPoint[1] - (start_pt[1]) |
|
451 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True |
|
452 |
dx = connector.sceneConnectPoint[0] - (end_pt[0]) |
|
453 |
dy = connector.sceneConnectPoint[1] - (end_pt[1]) |
|
454 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True |
|
463 |
for iConnector in item.connectors: |
|
464 |
dx = connector.sceneConnectPoint[0] - iConnector.sceneConnectPoint[0] |
|
465 |
dy = connector.sceneConnectPoint[1] - iConnector.sceneConnectPoint[1] |
|
466 |
if (math.sqrt(dx*dx + dy*dy) < toler): return True |
|
455 | 467 |
|
456 | 468 |
return False |
457 | 469 |
|
내보내기 Unified diff