개정판 baa87c88
ars pdf markup, batch pdf test
Change-Id: I3ef2fa016ca2dddc02dd6019457a55b2d97b17d8
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
82 | 82 |
#self._hmbTable = None |
83 | 83 |
self._hmbColors = {} |
84 | 84 |
self._hmbData = None |
85 |
self._arsColors = {} |
|
85 | 86 |
self._streamLineListModelDatas = [] |
86 | 87 |
self._titleBlockProperties = None |
87 | 88 |
self.needReOpening = None |
... | ... | |
175 | 176 |
#self._hmbTable = None |
176 | 177 |
self._hmbColors = {} |
177 | 178 |
self._hmbData = None |
179 |
#self._arsColors = {} |
|
178 | 180 |
self._streamLineListModelDatas = [] |
179 | 181 |
self._titleBlockProperties = None |
180 | 182 |
|
DTI_PID/DTI_PID/DisplayColors.py | ||
---|---|---|
15 | 15 |
DisplayByLineNo = 1 |
16 | 16 |
DisplayByLineType = 2 |
17 | 17 |
DisplayByStreamNo = 3 |
18 |
DisplayByARS = 4 |
|
18 | 19 |
|
19 | 20 |
|
20 | 21 |
class DisplayColors(SingletonInstance): |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1496 | 1496 |
f"{sys.exc_info()[-1].tb_lineno}" |
1497 | 1497 |
self.addMessage.emit(MessageType.Error, message) |
1498 | 1498 |
|
1499 |
def on_export_PDF_ARS(self): |
|
1500 |
pass |
|
1499 |
def on_export_PDF_ARS(self, path): |
|
1500 |
drawingList = self.treeWidgetDrawingList.topLevelItem(0) |
|
1501 |
for idx in range(drawingList.childCount()): |
|
1502 |
child = drawingList.child(idx) |
|
1503 |
child.setCheckState(0, Qt.Checked) |
|
1504 |
|
|
1505 |
self.on_export_PDF(path) |
|
1501 | 1506 |
|
1502 |
def on_export_PDF(self): |
|
1507 |
def on_export_PDF(self, path=None):
|
|
1503 | 1508 |
# save alarm |
1504 | 1509 |
self.save_alarm_enable(False) |
1505 | 1510 |
|
... | ... | |
1550 | 1555 |
elif len(checked_drawings) > 1: |
1551 | 1556 |
name = os.path.join(project.getTempPath(), 'Select a Folder') |
1552 | 1557 |
|
1553 |
options = QFileDialog.Options() |
|
1554 |
options |= QFileDialog.DontUseNativeDialog |
|
1555 |
file_name, _ = QFileDialog.getSaveFileName(self, "Export PDF", name, "pdf files(*.pdf)", options=options) |
|
1556 |
if file_name: |
|
1557 |
directory = os.path.dirname(file_name) |
|
1558 |
file_name = None |
|
1559 |
if not path: |
|
1560 |
options = QFileDialog.Options() |
|
1561 |
options |= QFileDialog.DontUseNativeDialog |
|
1562 |
file_name, _ = QFileDialog.getSaveFileName(self, "Export PDF", name, "pdf files(*.pdf)", options=options) |
|
1563 |
|
|
1564 |
if file_name or path: |
|
1565 |
if file_name: |
|
1566 |
directory = os.path.dirname(file_name) |
|
1567 |
else: |
|
1568 |
directory = path |
|
1558 | 1569 |
|
1559 | 1570 |
self.progress_bar.setMaximum(len(checked_drawings) + 1) |
1560 | 1571 |
self.progress_bar.setValue(0) |
1561 | 1572 |
|
1562 | 1573 |
count = 0 |
1563 | 1574 |
for drawing in checked_drawings.keys(): |
1564 |
self.open_image_drawing(drawing, force=True, ocrUnknown=False) |
|
1575 |
self.open_image_drawing(drawing, force=True, ocrUnknown=False, timer=False, pdf=True)
|
|
1565 | 1576 |
|
1566 | 1577 |
self.save_PDF(os.path.join(directory, drawing.name)) |
1567 | 1578 |
|
1568 | 1579 |
count += 1 |
1569 | 1580 |
self.progress_bar.setValue(count) |
1570 |
#self.open_image_drawing(drawing, force=True, ocrUnknown=False) # for reset
|
|
1581 |
self.open_image_drawing(drawing, force=True, ocrUnknown=False) # for reset |
|
1571 | 1582 |
self.progress_bar.setValue(self.progress_bar.maximum()) |
1572 | 1583 |
|
1573 | 1584 |
QMessageBox.about(self, self.tr("Information"), self.tr('Successfully saved.')) |
1574 | 1585 |
|
1575 |
self.save_alarm_enable(True)
|
|
1586 |
#self.save_alarm_enable(True, True)
|
|
1576 | 1587 |
|
1577 | 1588 |
''' |
1578 | 1589 |
#app_doc_data = AppDocData.instance() |
... | ... | |
2066 | 2077 |
|
2067 | 2078 |
def display_colors(self, value): |
2068 | 2079 |
""" display colors """ |
2069 |
from DisplayColors import DisplayColors |
|
2070 |
from DisplayColors import DisplayOptions |
|
2080 |
from DisplayColors import DisplayColors, DisplayOptions |
|
2071 | 2081 |
|
2072 | 2082 |
if hasattr(self, 'ribbon'): |
2073 | 2083 |
visualization_pane = self.ribbon.get_pane('Home Visualization') |
... | ... | |
2085 | 2095 |
item.update() |
2086 | 2096 |
DisplayColors.instance().save_data() |
2087 | 2097 |
|
2088 |
def open_image_drawing(self, drawing, force=False, ocrUnknown=False): |
|
2098 |
def open_image_drawing(self, drawing, force=False, ocrUnknown=False, timer=True, pdf=False):
|
|
2089 | 2099 |
"""open and display image drawing file""" |
2090 | 2100 |
from Drawing import Drawing |
2091 | 2101 |
from App import App |
... | ... | |
2117 | 2127 |
if not force and self.save_drawing_if_necessary(): |
2118 | 2128 |
return |
2119 | 2129 |
|
2120 |
occupied = app_doc_data.set_occupying_drawing(drawing.UID) |
|
2121 |
if occupied: |
|
2122 |
QMessageBox.about(self.graphicsView, self.tr("Notice"), |
|
2123 |
self.tr(f"The drawing is locked for editing by another user({occupied})")) |
|
2124 |
return |
|
2130 |
if not pdf: |
|
2131 |
occupied = app_doc_data.set_occupying_drawing(drawing.UID) |
|
2132 |
if occupied: |
|
2133 |
QMessageBox.about(self.graphicsView, self.tr("Notice"), |
|
2134 |
self.tr(f"The drawing is locked for editing by another user({occupied})")) |
|
2135 |
return |
|
2125 | 2136 |
|
2126 | 2137 |
# save alarm |
2127 |
self.save_alarm_enable(False) |
|
2138 |
if timer: |
|
2139 |
self.save_alarm_enable(False) |
|
2128 | 2140 |
|
2129 | 2141 |
if hasattr(self, '_save_work_cmd'): |
2130 | 2142 |
self._save_work_cmd.wait() |
... | ... | |
2177 | 2189 |
cmd.set_maximum.connect(self.progress.setMaximum) |
2178 | 2190 |
cmd.show_progress.connect(self.progress.setValue) |
2179 | 2191 |
cmd.execute((drawing, self.graphicsView.scene()), |
2180 |
symbol=True, text=True, line=True, unknown=True, package=True, update=True)
|
|
2192 |
symbol=True, text=True, line=True, unknown=True, package=True, update=not pdf)
|
|
2181 | 2193 |
|
2182 | 2194 |
configs = app_doc_data.getConfigs('Line List', 'Use Stream No') |
2183 | 2195 |
if configs and int(configs[0].value) == 1: |
... | ... | |
2240 | 2252 |
self.changeViewCheckedState(None) |
2241 | 2253 |
self.updateAsViewCheckedState() |
2242 | 2254 |
self.setWindowTitle(self.title) |
2243 |
self.fitWindow(drawing.view_rect) |
|
2255 |
if not pdf: |
|
2256 |
self.fitWindow(drawing.view_rect) |
|
2244 | 2257 |
|
2245 | 2258 |
if ocrUnknown: |
2246 | 2259 |
self.on_ocr_unknown_items() |
2247 | 2260 |
|
2248 | 2261 |
# save alarm |
2249 |
self.save_alarm_enable(True, True) |
|
2262 |
if timer: |
|
2263 |
self.save_alarm_enable(True, True) |
|
2250 | 2264 |
except Exception as ex: |
2251 | 2265 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
2252 | 2266 |
f"{sys.exc_info()[-1].tb_lineno}" |
DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py | ||
---|---|---|
88 | 88 |
return False |
89 | 89 |
|
90 | 90 |
try: |
91 |
app_doc_data = AppDocData.instance() |
|
92 |
|
|
91 | 93 |
if DisplayOptions.DisplayByStreamNo == DisplayColors.instance().option and \ |
92 | 94 |
(issubclass(type(self), SymbolSvgItem) or type(self) is QEngineeringLineItem): |
93 |
app_doc_data = AppDocData.instance() |
|
94 | 95 |
res = check_stream_no_attribute() |
95 | 96 |
if res and res in app_doc_data._hmbColors: |
96 | 97 |
return app_doc_data._hmbColors[res] |
97 | 98 |
else: |
98 | 99 |
return QEngineeringAbstractItem.DEFAULT_COLOR |
100 |
|
|
101 |
if DisplayOptions.DisplayByARS == DisplayColors.instance().option and \ |
|
102 |
(issubclass(type(self), SymbolSvgItem) or type(self) is QEngineeringLineItem): |
|
103 |
if str(self.uid) in app_doc_data._arsColors: |
|
104 |
return app_doc_data._arsColors[str(self.uid)] |
|
105 |
else: |
|
106 |
return QEngineeringAbstractItem.DEFAULT_COLOR |
|
99 | 107 |
|
100 | 108 |
if type(self) is QEngineeringEquipmentItem: |
101 | 109 |
# if DisplayOptions.DisplayByLineType == DisplayColors.instance().option: |
102 | 110 |
if self.hover: |
103 | 111 |
return SymbolSvgItem.HOVER_COLOR |
104 | 112 |
elif not QEngineeringEquipmentItem.EQUIP_COLOR: |
105 |
app_doc_data = AppDocData.instance() |
|
106 | 113 |
configs = app_doc_data.getConfigs('Equipment', 'Color') |
107 | 114 |
QEngineeringEquipmentItem.EQUIP_COLOR = configs[ |
108 | 115 |
0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR |
... | ... | |
114 | 121 |
return SymbolSvgItem.HOVER_COLOR |
115 | 122 |
elif DisplayOptions.DisplayByLineType == DisplayColors.instance().option: |
116 | 123 |
if not QEngineeringInstrumentItem.INST_COLOR: |
117 |
app_doc_data = AppDocData.instance() |
|
118 | 124 |
configs = app_doc_data.getConfigs('Instrument', 'Color') |
119 | 125 |
QEngineeringInstrumentItem.INST_COLOR = configs[ |
120 | 126 |
0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR |
... | ... | |
135 | 141 |
if self.lineType in QEngineeringLineItem.LINE_TYPE_COLORS: |
136 | 142 |
return QEngineeringLineItem.LINE_TYPE_COLORS[self.lineType] |
137 | 143 |
else: |
138 |
app_doc_data = AppDocData.instance() |
|
139 | 144 |
configs = app_doc_data.getConfigs('LineTypes', self.lineType) |
140 | 145 |
if configs: |
141 | 146 |
tokens = configs[0].value.split(',') |
DTI_PID/DTI_PID/TcpServer.py | ||
---|---|---|
134 | 134 |
data_pane = mainWnd.ribbon.get_pane('Data') |
135 | 135 |
data_pane.ui.toolButtonPSN.setChecked(False) |
136 | 136 |
''' |
137 |
elif jsonstr['request'] == 'ProcessEnd': |
|
138 |
pass |
|
137 |
elif jsonstr['request'] == 'Markup': |
|
138 |
import sqlite3 |
|
139 |
from DisplayColors import DisplayColors, DisplayOptions |
|
140 |
|
|
141 |
db_path = jsonstr['filepath'] |
|
142 |
pdf_path = jsonstr['path'] if jsonstr.get('path') else None |
|
143 |
|
|
144 |
with sqlite3.connect(db_path, isolation_level=None) as conn: |
|
145 |
try: |
|
146 |
conn.row_factory = sqlite3.Row |
|
147 |
|
|
148 |
cursor = conn.cursor() |
|
149 |
sql = 'SELECT DISTINCT [UID],[Color] FROM Markup' |
|
150 |
cursor.execute(sql) |
|
151 |
rows = cursor.fetchall() |
|
152 |
for row in rows: |
|
153 |
docData._arsColors[row['UID']] = '#' + row['Color'] |
|
154 |
# Catch the exception |
|
155 |
except Exception as ex: |
|
156 |
from App import App |
|
157 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
158 |
sys.exc_info()[-1].tb_lineno) |
|
159 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
|
160 |
|
|
161 |
dis_option = DisplayColors.instance().option |
|
162 |
DisplayColors.instance().option = DisplayOptions.DisplayByARS |
|
163 |
|
|
164 |
mainWnd.on_export_PDF_ARS(pdf_path) |
|
165 |
|
|
166 |
DisplayColors.instance().option = dis_option |
|
139 | 167 |
else: |
140 | 168 |
pass |
141 | 169 |
else: |
내보내기 Unified diff