개정판 5eb0183a
fix size
Change-Id: Ib3a6df19cdba6a30b183403352d1c558115d94be
DTI_PID/DTI_PID/ImportTextFromCADDialog.py | ||
---|---|---|
273 | 273 |
configs = app_doc_data.getConfigs('Cad Offset', 'Y Scale') |
274 | 274 |
self.ui.doubleSpinBox_2.setValue(float(configs[0].value)) if 1 == len(configs) else \ |
275 | 275 |
self.ui.doubleSpinBoxScale.setValue(0.5) |
276 |
|
|
276 | 277 |
self.text_scale = None |
278 |
self.id2_bbox = None |
|
277 | 279 |
|
278 | 280 |
self.isAccepted = False |
279 | 281 |
|
... | ... | |
286 | 288 |
|
287 | 289 |
def autoStateChanged(self, checkState): |
288 | 290 |
if checkState is int(Qt.Checked): |
289 |
pass |
|
291 |
self.ui.spinBoxX.setEnabled(False) |
|
292 |
self.ui.spinBoxY.setEnabled(False) |
|
293 |
self.ui.spinBoxTextX.setEnabled(False) |
|
294 |
self.ui.spinBoxTextY.setEnabled(False) |
|
295 |
self.ui.spinBoxSymbolX.setEnabled(False) |
|
296 |
self.ui.spinBoxSymbolY.setEnabled(False) |
|
297 |
self.ui.doubleSpinBoxScale.setEnabled(False) |
|
298 |
self.ui.doubleSpinBox.setEnabled(False) |
|
299 |
self.ui.doubleSpinBox_2.setEnabled(False) |
|
300 |
self.ui.lineEdit.setEnabled(False) |
|
301 |
self.ui.lineEdit_2.setEnabled(False) |
|
290 | 302 |
elif checkState is int(Qt.Unchecked): |
291 |
pass |
|
303 |
self.ui.spinBoxX.setEnabled(True) |
|
304 |
self.ui.spinBoxY.setEnabled(True) |
|
305 |
self.ui.spinBoxTextX.setEnabled(True) |
|
306 |
self.ui.spinBoxTextY.setEnabled(True) |
|
307 |
self.ui.spinBoxSymbolX.setEnabled(True) |
|
308 |
self.ui.spinBoxSymbolY.setEnabled(True) |
|
309 |
self.ui.doubleSpinBoxScale.setEnabled(True) |
|
310 |
self.ui.doubleSpinBox.setEnabled(True) |
|
311 |
self.ui.doubleSpinBox_2.setEnabled(True) |
|
312 |
self.ui.lineEdit.setEnabled(True) |
|
313 |
self.ui.lineEdit_2.setEnabled(True) |
|
292 | 314 |
|
293 | 315 |
def autoCalOffset(self): |
294 | 316 |
""" auto calculate offset """ |
... | ... | |
329 | 351 |
autocad_xml_path = os.path.join(os.path.dirname(_file), os.path.splitext(os.path.basename(_file))[0] + '.xml') |
330 | 352 |
matches = [id2_xml_file for id2_xml_file in id2_xml_files if id2_xml_file.replace(file_name, '').upper() == '.XML'] |
331 | 353 |
|
354 |
''' |
|
332 | 355 |
id2_xml_path = os.path.join(temp_path, matches[0]) |
333 | 356 |
id2_xml = parse(id2_xml_path) |
334 | 357 |
id2_xml_root = id2_xml.getroot() |
... | ... | |
340 | 363 |
id2_bbox = [0, 0, |
341 | 364 |
int(id2_xml_root.find('SIZE').text.split(',')[0]), |
342 | 365 |
int(id2_xml_root.find('SIZE').text.split(',')[1])] |
366 |
''' |
|
343 | 367 |
|
344 | 368 |
if matches: |
345 | 369 |
try: |
... | ... | |
354 | 378 |
|
355 | 379 |
if blk_tbl_record.attrib['Name'].upper() != '*Model_Space'.upper(): |
356 | 380 |
continue |
357 |
|
|
381 |
''' |
|
358 | 382 |
min_values = [float(token) for token in |
359 | 383 |
blk_tbl_record.attrib['MinExtents'].strip('(').strip(')').split(',')] |
360 | 384 |
max_values = [float(token) for token in |
361 | 385 |
blk_tbl_record.attrib['MaxExtents'].strip('(').strip(')').split(',')] |
362 | 386 |
autocad_bbox = [min_values[0], min_values[1], |
363 | 387 |
max_values[0] - min_values[0], max_values[1] - min_values[1]] |
388 |
''' |
|
364 | 389 |
for text_node in blk_tbl_record.iter('AcDbText'): |
365 | 390 |
if find_text_1 != text_node.text and find_text_2 != text_node.text: |
366 | 391 |
continue |
... | ... | |
755 | 780 |
from AppDocData import AppDocData |
756 | 781 |
import cv2 |
757 | 782 |
|
758 |
min_x, min_y, max_x, max_y = None, None, None, None
|
|
783 |
min_x, min_y, max_x, max_y, width, height = 0, 0, None, None, None, None
|
|
759 | 784 |
|
760 | 785 |
img = AppDocData.my_imread(file_path=img_file_path) |
786 |
max_x = img.shape[1] |
|
787 |
max_y = img.shape[0] |
|
788 |
width = img.shape[1] |
|
789 |
height = img.shape[0] |
|
761 | 790 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) |
762 | 791 |
img = cv2.bitwise_not(img) # background should be 'BLACK' |
763 | 792 |
contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) |
... | ... | |
770 | 799 |
|
771 | 800 |
del img |
772 | 801 |
|
773 |
return min_x, min_y, max_x - min_x, max_y - min_y |
|
802 |
return min_x, min_y, max_x - min_x, max_y - min_y, width, height
|
|
774 | 803 |
|
775 | 804 |
if not self._dwgs: |
776 | 805 |
QMessageBox.information(self, self.tr('Information'), self.tr('There is no selected file(s)')) |
... | ... | |
836 | 865 |
id2_xml = parse(id2_xml_path) |
837 | 866 |
id2_xml_root = id2_xml.getroot() |
838 | 867 |
|
839 |
#id2_bbox = [0, 0, 9600, 6781]#get_contents_size_from_image(id2_image_file) |
|
840 |
id2_bbox = get_contents_size_from_image(id2_image_file) |
|
841 |
id2_bbox_text = id2_bbox |
|
868 |
#id2_bbox = [0, 0, 9600, 6781] |
|
869 |
self.id2_bbox = get_contents_size_from_image(id2_image_file) |
|
842 | 870 |
|
843 | 871 |
if 'Symbol' in will_be_converted_items: |
844 | 872 |
symbols_node = id2_xml_root.find(xg.SYMBOL_LIST_NODE_NAME) |
... | ... | |
887 | 915 |
if 'Text' in will_be_converted_items: |
888 | 916 |
for record in blk_tbl_record.iter('AcDbText'): |
889 | 917 |
if record.attrib['Layer'] not in exclude_layers: |
890 |
node = self.text_to_xml(record, id2_bbox_text, autocad_bbox)
|
|
918 |
node = self.text_to_xml(record, self.id2_bbox, autocad_bbox)
|
|
891 | 919 |
if node: |
892 | 920 |
textInfo.append(node) |
893 | 921 |
|
894 | 922 |
for blk_ref in blk_tbl_record.iter('AcDbBlockReference'): |
895 | 923 |
if 'Symbol' in will_be_converted_items: |
896 | 924 |
if blk_ref.attrib['Layer'] not in exclude_layers: |
897 |
node = self.symbol_to_xml(blk_ref, id2_bbox, autocad_bbox, mapping_configs) |
|
925 |
node = self.symbol_to_xml(blk_ref, self.id2_bbox, autocad_bbox, mapping_configs)
|
|
898 | 926 |
if node: |
899 | 927 |
symbols_node.append(node) |
900 | 928 |
|
901 | 929 |
if 'Text' in will_be_converted_items: |
902 | 930 |
angle = round(float(blk_ref.attrib['Angle']), 2) |
903 | 931 |
for record in blk_ref.iter('AcDbAttribute'): |
904 |
node = self.text_to_xml(record, id2_bbox_text, autocad_bbox)
|
|
932 |
node = self.text_to_xml(record, self.id2_bbox, autocad_bbox)
|
|
905 | 933 |
if node: |
906 | 934 |
textInfo.append(node) |
907 | 935 |
|
908 | 936 |
if 'Line' in will_be_converted_items: |
909 | 937 |
for record in blk_tbl_record.iter('AcDbLine'): |
910 | 938 |
if record.attrib['Layer'] not in exclude_layers: |
911 |
nodes = self.lines_to_xml(layers, line_types, record, id2_bbox, autocad_bbox) |
|
939 |
nodes = self.lines_to_xml(layers, line_types, record, self.id2_bbox, autocad_bbox)
|
|
912 | 940 |
if nodes: |
913 | 941 |
for node in nodes: |
914 | 942 |
line_infos.append(node) |
915 | 943 |
|
916 | 944 |
for record in blk_tbl_record.iter('AcDbPolyline'): |
917 | 945 |
if record.attrib['Layer'] not in exclude_layers: |
918 |
nodes = self.lines_to_xml(layers, line_types, record, id2_bbox, autocad_bbox) |
|
946 |
nodes = self.lines_to_xml(layers, line_types, record, self.id2_bbox, autocad_bbox)
|
|
919 | 947 |
if nodes: |
920 | 948 |
for node in nodes: |
921 | 949 |
line_infos.append(node) |
... | ... | |
1042 | 1070 |
from EngineeringTextItem import QEngineeringTextItem |
1043 | 1071 |
|
1044 | 1072 |
try: |
1045 |
scale_x = max([id2_bbox[2] / autocad_bbox[2], id2_bbox[3] / autocad_bbox[3]]) \
|
|
1073 |
scale_x = id2_bbox[2] / autocad_bbox[2] \
|
|
1046 | 1074 |
if self.ui.doubleSpinBox.value() < 1 else self.ui.doubleSpinBox.value() |
1047 |
scale_y = max([id2_bbox[2] / autocad_bbox[2], id2_bbox[3] / autocad_bbox[3]]) \
|
|
1075 |
scale_y = id2_bbox[3] / autocad_bbox[3] \
|
|
1048 | 1076 |
if self.ui.doubleSpinBox_2.value() < 1 else self.ui.doubleSpinBox_2.value() |
1049 |
offsets = [id2_bbox[0] - autocad_bbox[0] * scale_x, (id2_bbox[1] + id2_bbox[3]) - autocad_bbox[1] * scale_y]
|
|
1077 |
offsets = [id2_bbox[0] - autocad_bbox[0] * scale_x, (id2_bbox[5] + id2_bbox[1]) + autocad_bbox[1] * scale_y]
|
|
1050 | 1078 |
|
1051 | 1079 |
#offsets = [self.ui.spinBoxTextX.value(), (id2_bbox[1] + id2_bbox[3]) + self.ui.spinBoxTextY.value()] |
1052 | 1080 |
|
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py | ||
---|---|---|
1015 | 1015 |
if sizes[index][2] != sizes[index + 1][1]: |
1016 | 1016 |
if type(sizes[index][0]) is not QEngineeringReducerItem and type(sizes[index + 1][0]) is not QEngineeringReducerItem \ |
1017 | 1017 |
and (hasattr(sizes[index][0], 'iType') and type(sizes[index][0]).iType != 22) and \ |
1018 |
(hasattr(sizes[index][0], 'iType') and type(sizes[index + 1][0]) != 22): |
|
1018 |
(hasattr(sizes[index + 1][0], 'iType') and type(sizes[index + 1][0]) != 22):
|
|
1019 | 1019 |
size_errors.append(sizes[index][0]) |
1020 | 1020 |
size_errors.append(sizes[index + 1][0]) |
1021 | 1021 |
|
내보내기 Unified diff