개정판 afb057b0
save pdf fix
Change-Id: I24862e4b050614e91dfabcad65c9b60a80ca34c6
DTI_PID/DTI_PID/LineNoTracer.py | ||
---|---|---|
255 | 255 |
remainLineNo1.append(line_no) |
256 | 256 |
|
257 | 257 |
for line_no in remainLineNo1: |
258 |
_from = line_no.prop('From') |
|
259 |
_to = line_no.prop('To') |
|
260 |
|
|
258 | 261 |
if _from: |
259 | 262 |
_from.owner = line_no |
260 | 263 |
line_no.set_property('To', None) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1037 | 1037 |
if originPoint.distance(Point(attribute_table_item[1][1].center().x(), attribute_table_item[1][1].center().y())) < dist_range: |
1038 | 1038 |
if issubclass(type(upItem), SymbolSvgItem): |
1039 | 1039 |
symbolPoint = Point(upItem.origin[0], upItem.origin[1]) |
1040 |
if symbolPoint.distance(Point(attribute_table_item[1][0].center().x(), attribute_table_item[1][0].center().y())) < \
|
|
1041 |
symbolPoint.distance(Point(attribute_table_item[1][1].center().x(), attribute_table_item[1][1].center().y())):
|
|
1040 |
if symbolPoint.distance(Point(attribute_table_item[1][0].sceneBoundingRect().left(), attribute_table_item[1][0].sceneBoundingRect().top())) < \
|
|
1041 |
symbolPoint.distance(Point(attribute_table_item[1][1].sceneBoundingRect().left(), attribute_table_item[1][1].sceneBoundingRect().top())):
|
|
1042 | 1042 |
upText = attribute_table_item[1][0] |
1043 | 1043 |
downText = attribute_table_item[1][1] |
1044 | 1044 |
else: |
... | ... | |
1046 | 1046 |
downText = attribute_table_item[1][0] |
1047 | 1047 |
elif issubclass(type(downItem), SymbolSvgItem): |
1048 | 1048 |
symbolPoint = Point(downItem.origin[0], downItem.origin[1]) |
1049 |
if symbolPoint.distance(Point(attribute_table_item[1][0].center().x(), attribute_table_item[1][0].center().y())) < \
|
|
1050 |
symbolPoint.distance(Point(attribute_table_item[1][1].center().x(), attribute_table_item[1][1].center().y())):
|
|
1049 |
if symbolPoint.distance(Point(attribute_table_item[1][0].sceneBoundingRect().left(), attribute_table_item[1][0].sceneBoundingRect().top())) < \
|
|
1050 |
symbolPoint.distance(Point(attribute_table_item[1][1].sceneBoundingRect().left(), attribute_table_item[1][1].sceneBoundingRect().top())):
|
|
1051 | 1051 |
downText = attribute_table_item[1][0] |
1052 | 1052 |
upText = attribute_table_item[1][1] |
1053 | 1053 |
else: |
... | ... | |
1498 | 1498 |
return |
1499 | 1499 |
|
1500 | 1500 |
try: |
1501 |
app_doc_data = AppDocData.instance() |
|
1502 |
project = app_doc_data.getCurrentProject() |
|
1503 |
name = os.path.join(project.getTempPath(), os.path.splitext(app_doc_data.activeDrawing.name)[0]) + '.png' |
|
1504 |
|
|
1505 |
options = QFileDialog.Options() |
|
1506 |
options |= QFileDialog.DontUseNativeDialog |
|
1507 |
file_name, _ = QFileDialog.getSaveFileName(self, "Export PDF", name, "pdf files(*.pdf)", options=options) |
|
1508 |
if file_name: |
|
1509 |
#pixMap = self.graphicsView.grab(QRect(QPoint(0, 0), QSize(int(self.graphicsView.scene().sceneRect().width()), int(self.graphicsView.scene().sceneRect().height())))) |
|
1510 |
#pixMap.save(name) |
|
1511 |
#return |
|
1512 |
|
|
1513 |
image = QImage(QSize(int(self.graphicsView.scene().sceneRect().width()), int(self.graphicsView.scene().sceneRect().height())), QImage.Format_ARGB32_Premultiplied) |
|
1514 |
painter = QPainter(image) |
|
1515 |
scene = self.graphicsView.scene() |
|
1516 |
canvasRect = scene.sceneRect() # or canvasRect = scene.border.boundingRect() |
|
1517 |
source = canvasRect |
|
1518 |
scene.render(painter, QRectF(image.rect()), source) |
|
1519 |
image.save(name) |
|
1520 |
image = Image.open(name) |
|
1521 |
image = image.convert('RGB') |
|
1522 |
image.save(name.replace('.png', '.pdf')) |
|
1523 |
os.remove(name.replace('.pdf', '.png')) |
|
1524 |
|
|
1525 |
QMessageBox.about(self, self.tr("Information"), self.tr('Successfully saved.')) |
|
1526 |
return |
|
1527 |
|
|
1528 |
''' |
|
1501 | 1529 |
#app_doc_data = AppDocData.instance() |
1502 | 1530 |
#project = app_doc_data.getCurrentProject() |
1503 | 1531 |
|
... | ... | |
1528 | 1556 |
#for item in scene.items(): |
1529 | 1557 |
# if not hasattr(item, 'connectors'): continue |
1530 | 1558 |
# for connector in item.connectors: connector.setVisible(True) |
1559 |
''' |
|
1531 | 1560 |
|
1532 | 1561 |
except Exception as ex: |
1533 | 1562 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
내보내기 Unified diff