개정판 39e06d4b
issue #000 : Save 방식 변경 - Progress
Change-Id: I5b3734e51cb91ea3f4b07f40052e0ad3ebb12400
HYTOS/HYTOS/AppDocData.py | ||
---|---|---|
2801 | 2801 |
|
2802 | 2802 |
return result |
2803 | 2803 |
|
2804 |
def saveToDatabase(self, items): |
|
2804 |
|
|
2805 |
''' |
|
2806 |
@brief save to database |
|
2807 |
@author yjkim |
|
2808 |
@date 2019.08.28 |
|
2809 |
''' |
|
2810 |
def saveToDatabase(self, item, index): |
|
2805 | 2811 |
""" save given items to database """ |
2806 | 2812 |
try: |
2807 | 2813 |
# Creates or opens a file called mydb with a SQLite3 DB |
... | ... | |
2812 | 2818 |
|
2813 | 2819 |
uid = self.activeDrawing.UID |
2814 | 2820 |
|
2815 |
# delete Points |
|
2816 |
sql = "delete from Points where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
|
2817 |
cursor.execute(sql) |
|
2818 |
|
|
2819 |
# delete HMB |
|
2820 |
sql = "delete from HMB where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
|
2821 |
cursor.execute(sql) |
|
2821 |
if index == 0: |
|
2822 |
# delete Points |
|
2823 |
sql = "delete from Points where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid) |
|
2824 |
cursor.execute(sql) |
|
2822 | 2825 |
|
2823 |
# delete Components
|
|
2824 |
sql = "delete from Components where Drawings_UID = '{}'".format(uid)
|
|
2825 |
cursor.execute(sql) |
|
2826 |
# delete HMB
|
|
2827 |
sql = "delete from HMB where Components_UID in (select UID from Components where Drawings_UID = '{}')".format(uid)
|
|
2828 |
cursor.execute(sql)
|
|
2826 | 2829 |
|
2827 |
for item in items: |
|
2828 |
sql = item.toSql() |
|
2829 |
if type(sql) is list: |
|
2830 |
for item in sql: |
|
2831 |
if item is not None and 2 == len(item): |
|
2832 |
cursor.execute(item[0], item[1]) |
|
2833 |
else: |
|
2834 |
if sql is not None and 2 == len(sql): |
|
2835 |
cursor.execute(sql[0], sql[1]) |
|
2830 |
# delete Components |
|
2831 |
sql = "delete from Components where Drawings_UID = '{}'".format(uid) |
|
2832 |
cursor.execute(sql) |
|
2833 |
|
|
2834 |
sql = item.toSql() |
|
2835 |
if type(sql) is list: |
|
2836 |
for item in sql: |
|
2837 |
if item is not None and 2 == len(item): |
|
2838 |
cursor.execute(item[0], item[1]) |
|
2839 |
else: |
|
2840 |
if sql is not None and 2 == len(sql): |
|
2841 |
cursor.execute(sql[0], sql[1]) |
|
2836 | 2842 |
|
2837 | 2843 |
conn.commit() |
2838 | 2844 |
# Catch the exception |
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
443 | 443 |
appDocData.activeDrawing.allItems.append(item) |
444 | 444 |
if issubclass(type(item), QEngineeringTextItem): |
445 | 445 |
appDocData.texts.append(item) |
446 |
## |
|
447 |
|
|
448 |
itemTypes = [] |
|
449 |
for item in items: |
|
450 |
typeExist = False |
|
451 |
for itemType in itemTypes: |
|
452 |
if type(item) is itemType: |
|
453 |
typeExist = True |
|
454 |
break |
|
455 |
if not typeExist: |
|
456 |
itemTypes.append(type(item)) |
|
457 |
## |
|
458 |
|
|
459 |
#SaveWorkCommand.save() |
|
460 |
self._save_work_cmd = SaveWorkCommand() |
|
461 |
self._save_work_cmd.display_message.connect(self.onAddMessage) |
|
462 |
self._save_work_cmd.finished.connect(self.save_finished) |
|
463 |
|
|
464 |
""" show spinner gif animation """ |
|
465 |
self.label_spinner.setWindowFlags(Qt.WindowStaysOnTopHint) |
|
466 |
if not hasattr(self, '_movie'): |
|
467 |
self._movie = QMovie(':/newPrefix/spinner.gif') |
|
468 |
self.label_spinner.setMovie(self._movie) |
|
446 |
|
|
447 |
count = len(appDocData.activeDrawing.allItems) |
|
448 |
if count > 0: |
|
449 |
try: |
|
450 |
self.progress = QProgressDialog(self.tr("Please wait for a while"), self.tr("Cancel"), 0, 100, self) if not hasattr(self, 'progress') else self.progress |
|
451 |
self.progress.setWindowModality(Qt.WindowModal) |
|
452 |
self.progress.setAutoReset(True) |
|
453 |
self.progress.setAutoClose(True) |
|
454 |
self.progress.setMinimum(0) |
|
455 |
self.progress.resize(600,100) |
|
456 |
self.progress.setWindowTitle(self.tr("Save data...")) |
|
457 |
self.progress.show() |
|
469 | 458 |
|
470 |
self.label_spinner.show() |
|
471 |
self._movie.start() |
|
459 |
self.save_drawing_data() |
|
460 |
self.load_drawing_list() |
|
461 |
finally: |
|
462 |
self.progress.setValue(self.progress.maximum()) |
|
463 |
self.progress.hide() |
|
472 | 464 |
|
473 |
self._save_work_cmd.start() |
|
474 | 465 |
except Exception as ex: |
475 | 466 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
476 | 467 |
self.addMessage.emit(MessageType.Error, message) |
477 | 468 |
|
478 |
def save_finished(self): |
|
479 |
""" stop movie and hide label after finishing save """ |
|
480 |
self._movie.stop() |
|
481 |
self.label_spinner.hide() |
|
482 |
QMessageBox.information(self, self.tr('Notice'), self._save_work_cmd.resultStr) |
|
483 |
|
|
484 |
self.load_drawing_list() |
|
469 |
def save_drawing_data(self): |
|
470 |
from datetime import datetime |
|
471 |
from AppDocData import AppDocData |
|
472 |
from SymbolSvgItem import SymbolSvgItem |
|
473 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
|
474 |
|
|
475 |
try: |
|
476 |
appDocData = AppDocData.instance() |
|
477 |
items = appDocData.activeDrawing.allItems |
|
478 |
|
|
479 |
maxValue = len(items) |
|
480 |
self.progress.setMaximum(maxValue) |
|
481 |
|
|
482 |
index = 0 |
|
483 |
for item in items: |
|
484 |
if type(item) is SymbolSvgItem or type(item) is QEngineeringStreamlineItem: |
|
485 |
appDocData.saveToDatabase(item, index) |
|
486 |
self.progress.setValue(index) |
|
487 |
index += 1 |
|
485 | 488 |
|
489 |
QApplication.processEvents() |
|
486 | 490 |
|
491 |
activeDrawing = appDocData.activeDrawing |
|
492 |
if activeDrawing is not None: |
|
493 |
activeDrawing.hmbTable.saveData() |
|
494 |
|
|
495 |
""" update drawing's modified time """ |
|
496 |
drawings = appDocData.getDrawings() |
|
497 |
drawing = [drawing for drawing in drawings if appDocData.imgName == os.path.splitext(drawing[1])[0]] |
|
498 |
if drawing[0]: |
|
499 |
drawing[0][2] = datetime.now().strftime('%Y-%m-%d %H:%M:%S') |
|
500 |
appDocData.updateDrawing(drawing) |
|
501 |
|
|
502 |
except Exception as ex: |
|
503 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
504 |
self.addMessage.emit(MessageType.Error, message) |
|
487 | 505 |
|
488 | 506 |
''' |
489 | 507 |
@brief add message listwidget |
... | ... | |
931 | 949 |
self.addMessage.emit(MessageType.Error, message) |
932 | 950 |
|
933 | 951 |
''' |
934 |
@history 2018.05.25 Jeongwoo Moved from MainWindow |
|
935 |
SvgItem and TextItem Connect with method in this class |
|
936 |
Change method to add GraphicsItem |
|
937 |
2018.05.28 Jeongwoo Make QGraphicsItem by symbol, text object. Not xml |
|
938 |
2018.05.29 Jeongwoo Change method name and Moved from QRecognitionDialog |
|
939 |
2018.05.30 Jeongwoo Add parameters on SymbolSvgItem.__init__() (parentSymbol, childSymbol) |
|
940 |
Change Method name and seperate each item |
|
941 |
humkyung 2018.06.11 display difference between original and recognized image |
|
942 |
Jeongwoo 2018.06.18 Update Scene after all item added |
|
943 |
2018.11.05 euisung add save note item because of dependency |
|
944 |
2018.11.05 euisung add db delete process before save |
|
945 |
2018.11.12 euisung add title block properties |
|
946 |
2018.11.12 euisung db part move new method to dbUpdate |
|
947 |
2018.11.26 euisung isolate scene adding part -> drawDetectedItemsToScene() |
|
948 |
2018.11.29 euisung change name drawDetectedItems() -> createDetectedItems |
|
949 |
''' |
|
950 |
def createDetectedItems(self, symbolList, textInfoList, otherTextInfoList, titleBlockTextInfoList): |
|
951 |
try: |
|
952 |
appDocData = AppDocData.instance() |
|
953 |
|
|
954 |
QApplication.processEvents() |
|
955 |
self.createDetectedSymbolItem(symbolList) |
|
956 |
QApplication.processEvents() |
|
957 |
self.createDetectedTextItem(textInfoList) |
|
958 |
QApplication.processEvents() |
|
959 |
self.createDetectedOtherTextItem(otherTextInfoList) |
|
960 |
QApplication.processEvents() |
|
961 |
self.createDetectedTitleBlockTextItem(titleBlockTextInfoList) |
|
962 |
|
|
963 |
self.dbUpdate() |
|
964 |
|
|
965 |
# update scene |
|
966 |
#self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
967 |
except Exception as ex: |
|
968 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
969 |
self.addMessage.emit(MessageType.Error, message) |
|
970 |
|
|
971 |
def drawDetectedItemsToScene(self): |
|
972 |
''' |
|
973 |
@brief add detected items to scene |
|
974 |
@author euisung |
|
975 |
@date 2018.11.26 |
|
976 |
''' |
|
977 |
appDocData = AppDocData.instance() |
|
978 |
|
|
979 |
try: |
|
980 |
for symbol in appDocData.symbols: |
|
981 |
if issubclass(type(symbol), SymbolSvgItem): |
|
982 |
self.addSvgItemToScene(symbol) |
|
983 |
else: |
|
984 |
self.graphicsView.scene.addItem(symbol) |
|
985 |
|
|
986 |
for text in appDocData.texts: |
|
987 |
self.addTextItemToScene(text) |
|
988 |
|
|
989 |
for lineNo in appDocData.tracerLineNos: |
|
990 |
self.addTextItemToScene(lineNo) |
|
991 |
|
|
992 |
for line in appDocData.lines: |
|
993 |
self.graphicsView.scene.addItem(line) |
|
994 |
line.transfer.onRemoved.connect(self.itemRemoved) |
|
995 |
for conn in line.connectors: |
|
996 |
conn.transfer.onPosChanged.connect(line.onConnectorPosChaned) |
|
997 |
|
|
998 |
for unknown in appDocData.unknowns + appDocData.lineIndicators: |
|
999 |
self.graphicsView.scene.addItem(unknown) |
|
1000 |
finally: |
|
1001 |
# update scene |
|
1002 |
self.graphicsView.scene.update(self.graphicsView.sceneRect()) |
|
1003 |
|
|
1004 |
def postDetectLineProcess(self): |
|
1005 |
''' |
|
1006 |
@brief check allowables among undetected items |
|
1007 |
@author euisung |
|
1008 |
@date 2018.11.15 |
|
1009 |
@history 2018.11.15 euisung no more used, moved to TextItemFactoy isLineNo() |
|
1010 |
''' |
|
1011 |
from AppDocData import AppDocData |
|
1012 |
from TextItemFactory import TextItemFactory |
|
1013 |
|
|
1014 |
appDocData = AppDocData.instance() |
|
1015 |
|
|
1016 |
tableNames = ["Fluid Code", "Insulation Purpose", "PnID Number", "Piping Materials Class", "Unit Number"] |
|
1017 |
tableDatas = [] |
|
1018 |
for tableName in tableNames: |
|
1019 |
tableNameFormat = tableName.replace(' ','').replace('&&', 'n') |
|
1020 |
tableDatas.append(appDocData.getCodeTable(tableNameFormat)) |
|
1021 |
|
|
1022 |
items = self.graphicsView.scene.items() |
|
1023 |
for item in items: |
|
1024 |
if type(item) is not QEngineeringTextItem: |
|
1025 |
continue |
|
1026 |
text = item.text() |
|
1027 |
for tableData in tableDatas: |
|
1028 |
for data in tableData: |
|
1029 |
if data[3] == '': |
|
1030 |
continue |
|
1031 |
else: |
|
1032 |
allows = data[3].split(',') |
|
1033 |
for allow in allows: |
|
1034 |
text = text.replace(allow, data[1]) |
|
1035 |
|
|
1036 |
lineItem = TextItemFactory.instance().createTextItem(text) |
|
1037 |
if type(lineItem) is QEngineeringLineNoTextItem: |
|
1038 |
lineItem.loc = item.loc |
|
1039 |
lineItem.size = item.size |
|
1040 |
lineItem.angle = item.angle |
|
1041 |
lineItem.area = item.area |
|
1042 |
#lineItem.addTextItemToScene(self.graphicsView.scene) |
|
1043 |
lineItem.transfer.onRemoved.connect(self.itemRemoved) |
|
1044 |
item.transfer.onRemoved.emit(item) |
|
1045 |
appDocData.lineNos.append(lineItem) |
|
1046 |
|
|
1047 |
def createDetectedTitleBlockTextItem(self, textInfoList): |
|
1048 |
''' |
|
1049 |
@brief draw title block |
|
1050 |
@author euisung |
|
1051 |
@date 2018.11.12 |
|
1052 |
@history 2018.11.26 euisung remove scene dependency |
|
1053 |
2018.11.29 euisung change name drawDetectedTitleBlockTextItem() -> createDetectedTitleBlockTextItem |
|
1054 |
''' |
|
1055 |
from TextItemFactory import TextItemFactory |
|
1056 |
import math |
|
1057 |
|
|
1058 |
try: |
|
1059 |
appDocData = AppDocData.instance() |
|
1060 |
|
|
1061 |
# parse texts |
|
1062 |
for textInfo in textInfoList: |
|
1063 |
if len(textInfo[1]) is 0: |
|
1064 |
continue |
|
1065 |
x = textInfo[1][0].getX() |
|
1066 |
y = textInfo[1][0].getY() |
|
1067 |
width = textInfo[1][0].getW() |
|
1068 |
height = textInfo[1][0].getH() |
|
1069 |
angle = round(math.radians(textInfo[1][0].getAngle()), 2) |
|
1070 |
text = textInfo[1][0].getText() |
|
1071 |
item = TextItemFactory.instance().createTextItem(textInfo) |
|
1072 |
|
|
1073 |
if item is not None: |
|
1074 |
item.loc = (x, y) |
|
1075 |
item.size = (width, height) |
|
1076 |
item.angle = angle |
|
1077 |
item.area = textInfo[0] |
|
1078 |
#self.addTextItemToScene(item) |
|
1079 |
#appDocData.texts.append(item) |
|
1080 |
appDocData.activeDrawing.allItems.append(item) |
|
1081 |
except Exception as ex: |
|
1082 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1083 |
self.addMessage.emit(MessageType.Error, message) |
|
1084 |
|
|
1085 |
''' |
|
1086 |
@brief |
|
1087 |
@author humkyung |
|
1088 |
@date 2018.08.23 |
|
1089 |
@history 2018.11.26 euisung remove scene dependency |
|
1090 |
2018.11.26 euisung isolate scene adding part -> drawDetectedItemsToScene() |
|
1091 |
2018.11. euisung no more used |
|
1092 |
2018.11.29 euisung change name drawDetectedLines() -> createDetectedLines |
|
1093 |
''' |
|
1094 |
def createDetectedLines(self, lineList, worker): |
|
1095 |
appDocData = AppDocData.instance() |
|
1096 |
area = appDocData.getArea('Drawing') |
|
1097 |
|
|
1098 |
for pts in lineList: |
|
1099 |
processLine = QEngineeringLineItem(vertices=[(area.x + param[0], area.y + param[1]) for param in pts]) |
|
1100 |
processLine.area = 'Drawing' |
|
1101 |
#self.graphicsView.scene.addItem(processLine) |
|
1102 |
appDocData.lines.append(processLine) |
|
1103 |
appDocData.activeDrawing.allItems.append(processLine) |
|
1104 |
|
|
1105 |
if processLine.length() > 100: # TODO: check critical length |
|
1106 |
processLine.addFlowArrow() |
|
1107 |
|
|
1108 |
# re-order process line's start,end according to flow mark |
|
1109 |
#worker.arrangeLinePosition(lines, symbols, listWidget) |
|
1110 |
# up to here |
|
1111 |
|
|
1112 |
''' |
|
1113 |
history 2018.06.09 humkyung check length of original and connection point is 2 while parsing |
|
1114 |
2018.11.26 euisung remove scene dependency |
|
1115 |
2018.11.29 euisung change name drawDetectedSymbolItem() -> createDetectedSymbolItem |
|
1116 |
''' |
|
1117 |
def createDetectedSymbolItem(self, symbolList): |
|
1118 |
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem |
|
1119 |
from SymbolSvgItem import SymbolSvgItem |
|
1120 |
import math |
|
1121 |
|
|
1122 |
try: |
|
1123 |
appDocData = AppDocData.instance() |
|
1124 |
project = appDocData.getCurrentProject() |
|
1125 |
|
|
1126 |
searchedMap = [] |
|
1127 |
for symbol in symbolList: |
|
1128 |
pt = [float(x) for x in symbol.getSp()] |
|
1129 |
size = [symbol.getWidth(), symbol.getHeight()] |
|
1130 |
name = symbol.getName() |
|
1131 |
angle = round(math.radians(symbol.getRotatedAngle()), 2) |
|
1132 |
category = symbol.getCategory() |
|
1133 |
_type = symbol.getType() |
|
1134 |
flip = symbol.getDetectFlip() |
|
1135 |
origin = [0,0] |
|
1136 |
if 2 == len(symbol.getOriginalPoint().split(',')): |
|
1137 |
tokens = symbol.getOriginalPoint().split(',') |
|
1138 |
origin = [pt[0] + float(tokens[0]), pt[1] + float(tokens[1])] |
|
1139 |
connPts = [] |
|
1140 |
if symbol.getConnectionPoint() is not None and symbol.getConnectionPoint() != '': |
|
1141 |
for param in symbol.getConnectionPoint().split('/'): |
|
1142 |
tokens = param.split(',') |
|
1143 |
connPts.append(('AUTO', pt[0] + float(tokens[0]), pt[1] + float(tokens[1]), '0') if len(tokens) == 2 else \ |
|
1144 |
(tokens[0], pt[0] + float(tokens[1]), pt[1] + float(tokens[2]), '0') if len(tokens) == 3 else \ |
|
1145 |
(tokens[0], pt[0] + float(tokens[1]), pt[1] + float(tokens[2]), tokens[3]) if len(tokens) == 4 else None) |
|
1146 |
|
|
1147 |
parentSymbol = symbol.getBaseSymbol() |
|
1148 |
childSymbol = symbol.getAdditionalSymbol() |
|
1149 |
hasInstrumentLabel = symbol.getHasInstrumentLabel() |
|
1150 |
|
|
1151 |
svgFilePath = os.path.join(project.getSvgFilePath(s), category, _type, name + '.svg') |
|
1152 |
if os.path.isfile(svgFilePath): |
|
1153 |
svg = SymbolSvgItem.createItem(_type, svgFilePath, owner=None, flip=flip) |
|
1154 |
#print(pt) |
|
1155 |
#print(origin) |
|
1156 |
svg.buildItem(name, _type, angle, pt, size, origin, connPts, parentSymbol, childSymbol, hasInstrumentLabel) |
|
1157 |
svg.reCalculationRotatedItem() |
|
1158 |
svg.area = 'Drawing' |
|
1159 |
|
|
1160 |
# set owner - 2018.07.20 added by humkyung |
|
1161 |
matches = [searched for searched in searchedMap if searched[0] == symbol.owner] |
|
1162 |
if len(matches) == 1: |
|
1163 |
svg.owner = matches[0][1] |
|
1164 |
searchedMap.append((symbol, svg)) |
|
1165 |
# up to here |
|
1166 |
|
|
1167 |
svg.transfer.onRemoved.connect(self.itemRemoved) |
|
1168 |
#self.addSvgItemToScene(svg) |
|
1169 |
appDocData.symbols.append(svg) |
|
1170 |
appDocData.activeDrawing.allItems.append(svg) |
|
1171 |
else: |
|
1172 |
item = QGraphicsBoundingBoxItem(pt[0], pt[1], size[0], size[1]) |
|
1173 |
item.isSymbol = True |
|
1174 |
item.angle = angle |
|
1175 |
item.setPen(QPen(Qt.red, 5, Qt.SolidLine)) |
|
1176 |
#self.graphicsView.scene.addItem(item) |
|
1177 |
#appDocData.symbols.append(item) |
|
1178 |
appDocData.activeDrawing.allItems.append(item) |
|
1179 |
# up to here |
|
1180 |
except Exception as ex: |
|
1181 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1182 |
self.addMessage.emit(MessageType.Error, message) |
|
1183 |
|
|
1184 |
''' |
|
1185 |
@history 2018.06.08 Jeongwoo Add parameter on round method |
|
1186 |
@history 2018.11.02 euisung Add save note text item |
|
1187 |
@history 2018.11.05 euisung delete save note text item and move to drawDetectedItems() |
|
1188 |
2018.11.26 euisung remove scene dependency |
|
1189 |
2018.11.29 euisung change name drawDetectedTextItem() -> createDetectedTextItem |
|
1190 |
''' |
|
1191 |
def createDetectedTextItem(self, textInfoList): |
|
1192 |
from TextItemFactory import TextItemFactory |
|
1193 |
import math |
|
1194 |
|
|
1195 |
try: |
|
1196 |
appDocData = AppDocData.instance() |
|
1197 |
|
|
1198 |
# parse texts |
|
1199 |
for textInfo in textInfoList: |
|
1200 |
x = textInfo.getX() |
|
1201 |
y = textInfo.getY() |
|
1202 |
width = textInfo.getW() |
|
1203 |
height = textInfo.getH() |
|
1204 |
angle = round(math.radians(textInfo.getAngle()), 2) |
|
1205 |
text = textInfo.getText() |
|
1206 |
if not text: continue |
|
1207 |
|
|
1208 |
item = TextItemFactory.instance().createTextItem(textInfo) |
|
1209 |
if item is not None: |
|
1210 |
item.loc = (x, y) |
|
1211 |
item.size = (width, height) |
|
1212 |
item.angle = angle |
|
1213 |
item.area = 'Drawing' |
|
1214 |
item.transfer.onRemoved.connect(self.itemRemoved) |
|
1215 |
#self.addTextItemToScene(item) |
|
1216 |
#appDocData.texts.append(item) |
|
1217 |
appDocData.activeDrawing.allItems.append(item) |
|
1218 |
except Exception as ex: |
|
1219 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1220 |
self.addMessage.emit(MessageType.Error, message) |
|
1221 |
|
|
1222 |
''' |
|
1223 |
@brief draw detected texts except which in drawing area |
|
1224 |
@history 2018.11.29 euisung change name drawDetectedOtherTextItem() -> createDetectedOtherTextItem |
|
1225 |
''' |
|
1226 |
def createDetectedOtherTextItem(self, otherTextInfoList): |
|
1227 |
from TextItemFactory import TextItemFactory |
|
1228 |
import math |
|
1229 |
|
|
1230 |
try: |
|
1231 |
appDocData = AppDocData.instance() |
|
1232 |
|
|
1233 |
# parse notes |
|
1234 |
for textInfoMap in otherTextInfoList: |
|
1235 |
if textInfoMap[0]=='Note': |
|
1236 |
pass |
|
1237 |
|
|
1238 |
for textInfo in textInfoMap[1]: |
|
1239 |
x = textInfo.getX() |
|
1240 |
y = textInfo.getY() |
|
1241 |
width = textInfo.getW() |
|
1242 |
height = textInfo.getH() |
|
1243 |
angle = round(math.radians(textInfo.getAngle())) |
|
1244 |
text = textInfo.getText() |
|
1245 |
|
|
1246 |
item = TextItemFactory.instance().createTextItem(textInfo) |
|
1247 |
|
|
1248 |
item.loc = (x, y) |
|
1249 |
item.size = (width, height) |
|
1250 |
item.angle = angle |
|
1251 |
item.area = textInfoMap[0] |
|
1252 |
item.transfer.onRemoved.connect(self.itemRemoved) |
|
1253 |
#appDocData.texts.append(item) |
|
1254 |
appDocData.activeDrawing.allItems.append(item) |
|
1255 |
except Exception as ex: |
|
1256 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1257 |
self.addMessage.emit(MessageType.Error, message) |
|
1258 |
|
|
1259 |
''' |
|
1260 | 952 |
@brief load components |
1261 | 953 |
@author yeonjin |
1262 |
@date 2019.07.30 |
|
954 |
@date 2019.07.30.
|
|
1263 | 955 |
''' |
1264 | 956 |
def load_components(self, componentsUID): |
1265 | 957 |
from EngineeringStreamlineItem import QEngineeringStreamlineItem |
1266 | 958 |
from EngineeringConnectorItem import QEngineeringConnectorItem |
1267 | 959 |
|
1268 | 960 |
try: |
1269 |
symbols = [] |
|
1270 |
lines = [] |
|
1271 |
|
|
1272 | 961 |
appDocData = AppDocData.instance() |
1273 |
project = appDocData.getCurrentProject() |
|
1274 | 962 |
|
1275 | 963 |
maxValue = len(componentsUID) |
1276 | 964 |
self.progress.setMaximum(maxValue) |
1277 | 965 |
|
1278 |
|
|
1279 | 966 |
for componentUID in componentsUID: |
1280 | 967 |
componentInfos = appDocData.getComponentByComponentUID(componentUID) |
1281 | 968 |
if (len(componentInfos)) > 0: |
... | ... | |
1290 | 977 |
item = SymbolSvgItem.fromDatabase(componentInfos) |
1291 | 978 |
if item is not None: |
1292 | 979 |
item.transfer.onRemoved.connect(self.itemRemoved) |
1293 |
symbols.append(item) |
|
980 |
#symbols.append(item)
|
|
1294 | 981 |
appDocData.symbols.append(item) |
1295 | 982 |
self.addSvgItemToScene(item) |
1296 | 983 |
|
내보내기 Unified diff