개정판 90008bc3
issue #563: add run sort second step : using first step's fixed run info, testing
Change-Id: Ia05dba3046cf344012541475d96cc4c7c7e9efe9
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
165 | 165 |
lineno.conns.clear() |
166 | 166 |
minDist = None |
167 | 167 |
startLine = None |
168 |
for line in self._lines:
|
|
168 |
for line in [line for line in self._lines if line.owner is None]:
|
|
169 | 169 |
dist = line.distanceTo((lineno.center().x(), lineno.center().y())) |
170 | 170 |
if (minDist is None) or (dist < minDist): |
171 | 171 |
minDist = dist |
172 | 172 |
startLine = line |
173 | 173 |
if (startLine is not None) and (minDist < toler): |
174 | 174 |
lineno.conns.append(startLine) |
175 |
if _from is None or _to is None:
|
|
175 |
if not _from or not _to:
|
|
176 | 176 |
startLine.owner = lineno |
177 | 177 |
|
178 | 178 |
if _from and _to and (type(_from) is QEngineeringLineItem or issubclass(type(_from), SymbolSvgItem)) and (type(_to) is QEngineeringLineItem or issubclass(type(_to), SymbolSvgItem)): |
179 | 179 |
_from.owner = lineno |
180 | 180 |
_to.owner = lineno |
181 |
lineno._fixed = True |
|
181 | 182 |
else: |
182 | 183 |
lineno.set_property('From', None) |
183 | 184 |
lineno.set_property('To', None) |
185 |
lineno._fixed = False |
|
184 | 186 |
|
185 | 187 |
maxValue = len(self._lineNos) + 1 ## line no's count + secondary line |
186 | 188 |
|
... | ... | |
694 | 696 |
lineNo.update_flow_mark(position, length) |
695 | 697 |
|
696 | 698 |
# sort run flow order |
697 |
fixed_runs = [] |
|
698 |
waiting_runs = [] |
|
699 |
fixed_run_infos = []
|
|
700 |
waiting_run_infos = []
|
|
699 | 701 |
runs = [] |
700 |
# first step : make fixed run using opc
|
|
702 |
# first step : make fixed run using symbol info
|
|
701 | 703 |
for lineNo in [lineNo for lineNo in docdata.tracerLineNos if len(lineNo.runs) > 0]: |
702 | 704 |
not_trim = True if type(lineNo) is QEngineeringLineNoTextItem else False |
703 | 705 |
run_index = 0 |
704 | 706 |
for run in lineNo.runs: |
705 | 707 |
not_secondary = True if run_index is 0 else False |
706 |
# runs can know flow directly |
|
708 |
|
|
709 |
# if from and to info already was entered, fix run flow |
|
710 |
if hasattr(lineNo, '_fixed') and lineNo._fixed and not_secondary: |
|
711 |
fixed_run_infos.append([run, lineNo, not_trim, not_secondary]) |
|
712 |
continue |
|
707 | 713 |
|
708 | 714 |
reference_symbols = [item for item in run.items if issubclass(type(item), SymbolSvgItem) and item.has_in_out_connector()] |
715 |
# runs can know flow directly |
|
709 | 716 |
if len(run.items) > 1 and len(reference_symbols) > 0: |
710 | 717 |
for reference_symbol in reference_symbols: |
711 |
reference_symbol_index = run.items.index(reference_symbol) |
|
712 | 718 |
# place at first |
713 | 719 |
if reference_symbol is run.items[0]: |
714 | 720 |
if len([connector_index for connector_index in reference_symbol.in_out_connector[0] \ |
... | ... | |
717 | 723 |
lineNo.reverse() |
718 | 724 |
else: |
719 | 725 |
run.reverse() |
720 |
fixed_runs.append([run, lineNo, not_trim, not_secondary]) |
|
726 |
fixed_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
721 | 727 |
break |
722 | 728 |
elif len([connector_index for connector_index in reference_symbol.in_out_connector[1] \ |
723 | 729 |
if reference_symbol.connectors[connector_index].connectedItem is run.items[1]]) > 0: |
724 |
fixed_runs.append([run, lineNo, not_trim, not_secondary]) |
|
730 |
fixed_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
725 | 731 |
break |
726 | 732 |
# place at last |
727 | 733 |
elif reference_symbol is run.items[-1]: |
... | ... | |
731 | 737 |
lineNo.reverse() |
732 | 738 |
else: |
733 | 739 |
run.reverse() |
734 |
fixed_runs.append([run, lineNo, not_trim, not_secondary]) |
|
740 |
fixed_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
735 | 741 |
break |
736 | 742 |
elif len([connector_index for connector_index in reference_symbol.in_out_connector[0] \ |
737 | 743 |
if reference_symbol.connectors[connector_index].connectedItem is run.items[1]]) > 0: |
738 |
fixed_runs.append([run, lineNo, not_trim, not_secondary]) |
|
744 |
fixed_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
739 | 745 |
break |
740 | 746 |
# place at middle |
741 | 747 |
else: |
... | ... | |
753 | 759 |
lineNo.reverse() |
754 | 760 |
else: |
755 | 761 |
run.reverse() |
756 |
fixed_runs.append([run, lineNo, not_trim, not_secondary]) |
|
762 |
fixed_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
757 | 763 |
break |
758 |
waiting_runs.append([run, lineNo, not_trim, not_secondary]) |
|
764 |
waiting_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
759 | 765 |
# only symbol runs doesn't need flow |
760 |
elif (len(run.items) is 1 and issubclass(type(run.items[0]), SymbolSvgItem)) or \ |
|
761 |
len([not_symbol for not_symbol in run.items if not issubclass(type(item), SymbolSvgItem)]) is 0: |
|
766 |
elif len(run.items) is 1 and issubclass(type(run.items[0]), SymbolSvgItem): |
|
762 | 767 |
runs.append([run, lineNo, not_trim, not_secondary]) |
763 | 768 |
# runs can't know flow directly |
764 | 769 |
else: |
765 |
waiting_runs.append([run, lineNo, not_trim, not_secondary]) |
|
770 |
waiting_run_infos.append([run, lineNo, not_trim, not_secondary])
|
|
766 | 771 |
run_index += 1 |
767 | 772 |
|
768 | 773 |
# second step : determine waiting run flow |
769 |
#remain_run = True |
|
770 |
#while remain_run: |
|
771 |
# for run_index in reversed(range(len(waiting_runs))): |
|
772 |
# for fixed_run in fixed_runs: |
|
774 |
remain_count_past = len(waiting_run_infos) |
|
775 |
while True: |
|
776 |
remain_count = 0 |
|
777 |
for run_index in reversed(range(len(waiting_run_infos))): |
|
778 |
waiting_run_info = waiting_run_infos[run_index] |
|
779 |
waiting_run = waiting_run_info[0] |
|
780 |
for fixed_run_info in fixed_run_infos: |
|
781 |
fixed_run = fixed_run_info[0] |
|
782 |
if len(waiting_run.items) > 1 and len(fixed_run.items) > 1: |
|
783 |
if waiting_run.items[0].is_connected(fixed_run.items[0]): |
|
784 |
if waiting_run_info[2] and waiting_run_info[3]: |
|
785 |
waiting_run_info[1].reverse() |
|
786 |
else: |
|
787 |
run.reverse() |
|
788 |
fixed_run_infos.append(waiting_run_info) |
|
789 |
waiting_run_infos.pop(run_index) |
|
790 |
elif waiting_run.items[0].is_connected(fixed_run.items[-1]): |
|
791 |
fixed_run_infos.append(waiting_run_info) |
|
792 |
waiting_run_infos.pop(run_index) |
|
793 |
elif waiting_run.items[-1].is_connected(fixed_run.items[-1]): |
|
794 |
if waiting_run_info[2] and waiting_run_info[3]: |
|
795 |
waiting_run_info[1].reverse() |
|
796 |
else: |
|
797 |
run.reverse() |
|
798 |
fixed_run_infos.append(waiting_run_info) |
|
799 |
waiting_run_infos.pop(run_index) |
|
800 |
elif waiting_run.items[-1].is_connected(fixed_run.items[0]): |
|
801 |
fixed_run_infos.append(waiting_run_info) |
|
802 |
waiting_run_infos.pop(run_index) |
|
803 |
else: |
|
804 |
remain_count += 1 |
|
805 |
elif len(fixed_run.items) > 1: |
|
806 |
if waiting_run.items[0].connectors[0].connectedItem is fixed_run.items[0]: |
|
807 |
waiting_run.reverse() |
|
808 |
fixed_run_infos.append(waiting_run_info) |
|
809 |
waiting_run_infos.pop(run_index) |
|
810 |
elif waiting_run.items[0].connectors[0].connectedItem is fixed_run.items[-1]: |
|
811 |
fixed_run_infos.append(waiting_run_info) |
|
812 |
waiting_run_infos.pop(run_index) |
|
813 |
elif waiting_run.items[0].connectors[1].connectedItem is fixed_run.items[-1]: |
|
814 |
waiting_run.reverse() |
|
815 |
fixed_run_infos.append(waiting_run_info) |
|
816 |
waiting_run_infos.pop(run_index) |
|
817 |
elif waiting_run.items[0].connectors[1].connectedItem is fixed_run.items[0]: |
|
818 |
fixed_run_infos.append(waiting_run_info) |
|
819 |
waiting_run_infos.pop(run_index) |
|
820 |
else: |
|
821 |
remain_count += 1 |
|
822 |
else: |
|
823 |
if waiting_run.items[0].connectors[0].connectedItem is fixed_run.items[0] and fixed_run.items[0].connectors[0].connectedItem is waiting_run.items[0]: |
|
824 |
waiting_run.reverse() |
|
825 |
fixed_run_infos.append(waiting_run_info) |
|
826 |
waiting_run_infos.pop(run_index) |
|
827 |
elif waiting_run.items[0].connectors[0].connectedItem is fixed_run.items[0] and fixed_run.items[0].connectors[1].connectedItem is waiting_run.items[0]: |
|
828 |
fixed_run_infos.append(waiting_run_info) |
|
829 |
waiting_run_infos.pop(run_index) |
|
830 |
elif waiting_run.items[0].connectors[1].connectedItem is fixed_run.items[0] and fixed_run.items[0].connectors[1].connectedItem is waiting_run.items[0]: |
|
831 |
waiting_run.reverse() |
|
832 |
fixed_run_infos.append(waiting_run_info) |
|
833 |
waiting_run_infos.pop(run_index) |
|
834 |
elif waiting_run.items[0].connectors[1].connectedItem is fixed_run.items[0] and fixed_run.items[0].connectors[0].connectedItem is waiting_run.items[0]: |
|
835 |
fixed_run_infos.append(waiting_run_info) |
|
836 |
waiting_run_infos.pop(run_index) |
|
837 |
else: |
|
838 |
remain_count += 1 |
|
839 |
if remain_count_past == remain_count: |
|
840 |
break |
|
841 |
else: |
|
842 |
remain_count_past = remain_count |
|
843 |
|
|
773 | 844 |
|
774 | 845 |
|
775 | 846 |
# trace special item |
내보내기 Unified diff