개정판 f1134b8b
issue #1059: 도면을 이미지 혹은 SVG 파일로 생성할지 옵션을 제공한다
Change-Id: Iab13bb8d88bfa5f353758b6345b40849a1ab009b
HYTOS/HYTOS/MainWindow.py | ||
---|---|---|
1554 | 1554 |
self.showImageSelectionMessageBox() |
1555 | 1555 |
return |
1556 | 1556 |
|
1557 |
svg_path = None |
|
1557 |
report_drawing = 'Use Image' |
|
1558 |
configs = app_doc_data.getAppConfigs('option', 'ReportDrawing') |
|
1559 |
if configs and configs[0].value: |
|
1560 |
report_drawing = configs[0].value |
|
1561 |
|
|
1562 |
report_drawing_path = None |
|
1558 | 1563 |
with NamedTemporaryFile() as f: |
1559 |
svg_path = f.name + '.svg'
|
|
1564 |
report_drawing_path = f.name + '.png' if report_drawing == 'Use Image' else '.svg'
|
|
1560 | 1565 |
|
1561 |
if svg_path:
|
|
1566 |
if report_drawing_path:
|
|
1562 | 1567 |
self.on_view_connector(False) # hide connector |
1563 |
self.graphicsView.save_as_svg(svg_path) # try to use save_as_svg when will generate svg file |
|
1568 |
if report_drawing == 'Use Image': |
|
1569 |
self.graphicsView.save_as_image(report_drawing_path) |
|
1570 |
else: |
|
1571 |
self.graphicsView.save_as_svg(report_drawing_path) # try to use save_as_svg when will generate svg file |
|
1564 | 1572 |
|
1565 | 1573 |
workspace = self.get_work_space() |
1566 | 1574 |
file_name = os.path.join(workspace, app_doc_data.activeDrawing.name + '.xlsx') |
... | ... | |
1589 | 1597 |
for page in range(pages): |
1590 | 1598 |
ws = wb.copy_worksheet(wb.get_sheet_by_name('Page')) |
1591 | 1599 |
ws.title = f"Page ({page_no})" |
1592 |
""" |
|
1593 |
cal_image = openpyxl.drawing.image.Image(image_path) # TODO: try to insert svg file instead of image |
|
1594 |
x_scale = MainWindow.PAPER_SIZE.width() / cal_image.width |
|
1595 |
y_scale = MainWindow.PAPER_SIZE.height() / cal_image.height |
|
1596 |
cal_image.width *= x_scale |
|
1597 |
cal_image.height *= y_scale |
|
1598 |
ws.add_image(cal_image, 'A1') |
|
1599 |
""" |
|
1600 |
|
|
1601 |
if report_drawing == 'Use Image': |
|
1602 |
cal_image = openpyxl.drawing.image.Image(report_drawing_path) |
|
1603 |
x_scale = MainWindow.PAPER_SIZE.width() / cal_image.width |
|
1604 |
y_scale = MainWindow.PAPER_SIZE.height() / cal_image.height |
|
1605 |
cal_image.width *= x_scale |
|
1606 |
cal_image.height *= y_scale |
|
1607 |
ws.add_image(cal_image, 'A1') |
|
1608 |
|
|
1600 | 1609 |
company_image = openpyxl.drawing.image.Image(company_image_path) |
1601 | 1610 |
company_image.width *= 0.8 |
1602 | 1611 |
company_image.height *= 0.7 |
... | ... | |
2203 | 2212 |
save_file_name = file_name if ext.upper() == '.XLSX' else name_without_ext + '.xlsx' |
2204 | 2213 |
wb.save(filename=save_file_name) |
2205 | 2214 |
|
2206 |
report_app_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ReportApp', |
|
2207 |
'ReportApp.exe') |
|
2215 |
if report_drawing == 'Use SVG': |
|
2216 |
report_app_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ReportApp', |
|
2217 |
'ReportApp.exe') |
|
2208 | 2218 |
|
2209 |
arguments = [report_app_path, save_file_name, svg_path] |
|
2210 |
res = subprocess.call(arguments) |
|
2211 |
if res == 0: |
|
2212 |
os.startfile(save_file_name) |
|
2213 |
QMessageBox.information(self, self.tr('Information'), self.tr('Report is done')) |
|
2219 |
arguments = [report_app_path, save_file_name, report_drawing_path] |
|
2220 |
res = subprocess.call(arguments) |
|
2221 |
if res == 0: |
|
2222 |
os.startfile(save_file_name) |
|
2223 |
QMessageBox.information(self, self.tr('Information'), self.tr('Report is done')) |
|
2224 |
else: |
|
2225 |
QMessageBox.information(self, self.tr('Information'), |
|
2226 |
self.tr(' Could not find excel file or svg file. ')) |
|
2227 |
|
|
2228 |
if save_file_name is not None: |
|
2229 |
os.remove(save_file_name) |
|
2214 | 2230 |
else: |
2215 |
QMessageBox.information(self, self.tr('Information'), |
|
2216 |
self.tr(' Could not find excel file or svg file. ')) |
|
2231 |
os.startfile(save_file_name) |
|
2217 | 2232 |
|
2218 |
if save_file_name is not None: |
|
2219 |
os.remove(save_file_name) |
|
2233 |
QMessageBox.information(self, self.tr('Information'), self.tr('Report is done')) |
|
2220 | 2234 |
except Exception as ex: |
2221 | 2235 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
2222 | 2236 |
f"{sys.exc_info()[-1].tb_lineno}" |
HYTOS/HYTOS/OptionsDialog.py | ||
---|---|---|
132 | 132 |
configs = app_doc_data.getAppConfigs('app', 'update_url') |
133 | 133 |
if configs and configs[0].value: |
134 | 134 |
self.ui.lineEditUpdateURL.setText(configs[0].value) |
135 |
|
|
136 |
configs = app_doc_data.getAppConfigs('option', 'ReportDrawing') |
|
137 |
if configs and configs[0].value: |
|
138 |
self.ui.radioButtonUseImage.setChecked(configs[0].value == 'Use Image') |
|
139 |
self.ui.radioButtonUseSVG.setChecked(configs[0].value == 'Use SVG') |
|
135 | 140 |
except Exception as ex: |
136 | 141 |
from App import App |
137 | 142 |
from AppDocData import MessageType |
... | ... | |
152 | 157 |
self._callout_text_color = self.ui.pushButtonCalloutTextColor.palette().color(QPalette.Background).name() |
153 | 158 |
text_checked = self.ui.checkBoxTextBold.isChecked() |
154 | 159 |
callout_checked = self.ui.checkBoxCalloutBold.isChecked() |
160 |
report_drawing = 'Use Image' if self.ui.radioButtonUseImage.isChecked() else 'Use SVG' |
|
155 | 161 |
|
156 | 162 |
configs.append(Config('option', 'WorkSpace', self.ui.lineEdit_WorkSpace.text())) |
157 | 163 |
configs.append(Config('option', 'TagFontSize', self._tag_font_size)) |
... | ... | |
161 | 167 |
configs.append(Config('option', 'TagBold', text_checked)) |
162 | 168 |
configs.append(Config('option', 'CalloutBold', callout_checked)) |
163 | 169 |
configs.append(Config('app', 'update_url', self.ui.lineEditUpdateURL.text())) |
170 |
configs.append(Config('option', 'ReportDrawing', report_drawing)) |
|
164 | 171 |
|
165 | 172 |
app_doc_data.saveAppConfigs(configs) |
166 | 173 |
|
HYTOS/HYTOS/Options_UI.py | ||
---|---|---|
14 | 14 |
class Ui_OptionsDialog(object): |
15 | 15 |
def setupUi(self, OptionsDialog): |
16 | 16 |
OptionsDialog.setObjectName("OptionsDialog") |
17 |
OptionsDialog.resize(482, 266)
|
|
17 |
OptionsDialog.resize(482, 293)
|
|
18 | 18 |
font = QtGui.QFont() |
19 | 19 |
font.setFamily("맑은 고딕") |
20 | 20 |
OptionsDialog.setFont(font) |
... | ... | |
30 | 30 |
self.gridLayout_2.addWidget(self.buttonBox, 5, 0, 1, 1) |
31 | 31 |
self.gridLayout_4 = QtWidgets.QGridLayout() |
32 | 32 |
self.gridLayout_4.setObjectName("gridLayout_4") |
33 |
self.label_6 = QtWidgets.QLabel(OptionsDialog) |
|
34 |
self.label_6.setObjectName("label_6") |
|
35 |
self.gridLayout_4.addWidget(self.label_6, 0, 0, 1, 1) |
|
36 | 33 |
self.lineEditUpdateURL = QtWidgets.QLineEdit(OptionsDialog) |
37 | 34 |
self.lineEditUpdateURL.setObjectName("lineEditUpdateURL") |
38 |
self.gridLayout_4.addWidget(self.lineEditUpdateURL, 0, 1, 1, 1) |
|
35 |
self.gridLayout_4.addWidget(self.lineEditUpdateURL, 1, 1, 1, 1) |
|
36 |
self.label_6 = QtWidgets.QLabel(OptionsDialog) |
|
37 |
self.label_6.setObjectName("label_6") |
|
38 |
self.gridLayout_4.addWidget(self.label_6, 1, 0, 1, 1) |
|
39 |
self.label_7 = QtWidgets.QLabel(OptionsDialog) |
|
40 |
self.label_7.setObjectName("label_7") |
|
41 |
self.gridLayout_4.addWidget(self.label_7, 0, 0, 1, 1) |
|
42 |
self.gridLayout_5 = QtWidgets.QGridLayout() |
|
43 |
self.gridLayout_5.setObjectName("gridLayout_5") |
|
44 |
self.radioButtonUseImage = QtWidgets.QRadioButton(OptionsDialog) |
|
45 |
self.radioButtonUseImage.setChecked(True) |
|
46 |
self.radioButtonUseImage.setObjectName("radioButtonUseImage") |
|
47 |
self.gridLayout_5.addWidget(self.radioButtonUseImage, 0, 0, 1, 1) |
|
48 |
self.radioButtonUseSVG = QtWidgets.QRadioButton(OptionsDialog) |
|
49 |
self.radioButtonUseSVG.setObjectName("radioButtonUseSVG") |
|
50 |
self.gridLayout_5.addWidget(self.radioButtonUseSVG, 0, 1, 1, 1) |
|
51 |
self.gridLayout_4.addLayout(self.gridLayout_5, 0, 1, 1, 1) |
|
39 | 52 |
self.gridLayout_2.addLayout(self.gridLayout_4, 3, 0, 1, 1) |
40 | 53 |
self.groupBox = QtWidgets.QGroupBox(OptionsDialog) |
41 | 54 |
font = QtGui.QFont() |
... | ... | |
174 | 187 |
_translate = QtCore.QCoreApplication.translate |
175 | 188 |
OptionsDialog.setWindowTitle(_translate("OptionsDialog", "Options")) |
176 | 189 |
self.label_6.setText(_translate("OptionsDialog", "Update URL : ")) |
190 |
self.label_7.setText(_translate("OptionsDialog", "Report : ")) |
|
191 |
self.radioButtonUseImage.setText(_translate("OptionsDialog", "Use Image")) |
|
192 |
self.radioButtonUseSVG.setText(_translate("OptionsDialog", "Use SVG")) |
|
177 | 193 |
self.groupBox.setTitle(_translate("OptionsDialog", "Directory")) |
178 | 194 |
self.label_2.setText(_translate("OptionsDialog", "Work Space :")) |
179 | 195 |
self.toolButton_WorkSpace.setText(_translate("OptionsDialog", "...")) |
HYTOS/HYTOS/UI/Options.ui | ||
---|---|---|
7 | 7 |
<x>0</x> |
8 | 8 |
<y>0</y> |
9 | 9 |
<width>482</width> |
10 |
<height>266</height>
|
|
10 |
<height>293</height>
|
|
11 | 11 |
</rect> |
12 | 12 |
</property> |
13 | 13 |
<property name="font"> |
... | ... | |
35 | 35 |
</item> |
36 | 36 |
<item row="3" column="0"> |
37 | 37 |
<layout class="QGridLayout" name="gridLayout_4"> |
38 |
<item row="0" column="0"> |
|
38 |
<item row="1" column="1"> |
|
39 |
<widget class="QLineEdit" name="lineEditUpdateURL"/> |
|
40 |
</item> |
|
41 |
<item row="1" column="0"> |
|
39 | 42 |
<widget class="QLabel" name="label_6"> |
40 | 43 |
<property name="text"> |
41 | 44 |
<string>Update URL : </string> |
42 | 45 |
</property> |
43 | 46 |
</widget> |
44 | 47 |
</item> |
48 |
<item row="0" column="0"> |
|
49 |
<widget class="QLabel" name="label_7"> |
|
50 |
<property name="text"> |
|
51 |
<string>Report : </string> |
|
52 |
</property> |
|
53 |
</widget> |
|
54 |
</item> |
|
45 | 55 |
<item row="0" column="1"> |
46 |
<widget class="QLineEdit" name="lineEditUpdateURL"/> |
|
56 |
<layout class="QGridLayout" name="gridLayout_5"> |
|
57 |
<item row="0" column="0"> |
|
58 |
<widget class="QRadioButton" name="radioButtonUseImage"> |
|
59 |
<property name="text"> |
|
60 |
<string>Use Image</string> |
|
61 |
</property> |
|
62 |
<property name="checked"> |
|
63 |
<bool>true</bool> |
|
64 |
</property> |
|
65 |
</widget> |
|
66 |
</item> |
|
67 |
<item row="0" column="1"> |
|
68 |
<widget class="QRadioButton" name="radioButtonUseSVG"> |
|
69 |
<property name="text"> |
|
70 |
<string>Use SVG</string> |
|
71 |
</property> |
|
72 |
</widget> |
|
73 |
</item> |
|
74 |
</layout> |
|
47 | 75 |
</item> |
48 | 76 |
</layout> |
49 | 77 |
</item> |
내보내기 Unified diff