개정판 f28a350a
issue #663: setCurrentPidSource method 제거로 인한 오류 수정
Change-Id: Ia7c67a83ae51228dee1d13344dc300a3f10302bd
DTI_PID/DTI_PID/AppDocData.py | ||
---|---|---|
23 | 23 |
import symbol |
24 | 24 |
from NominalPipeSize import NominalPipeSize |
25 | 25 |
|
26 |
|
|
26 | 27 |
class Config: |
27 | 28 |
def __init__(self, section, key, value): |
28 | 29 |
self.section = section |
... | ... | |
34 | 35 |
@author humkyung |
35 | 36 |
@date 2018.04.24 |
36 | 37 |
''' |
38 |
|
|
37 | 39 |
def sizeValue(self): |
38 | 40 |
return self.inchStr if 'Inch' == self.sizeUnit else self.metricStr |
39 | 41 |
|
42 |
|
|
40 | 43 |
''' |
41 | 44 |
@brief Pipe color class |
42 | 45 |
''' |
46 |
|
|
47 |
|
|
43 | 48 |
class Color: |
44 | 49 |
def __init__(self, index, red, green, blue): |
45 | 50 |
self.index = index |
... | ... | |
47 | 52 |
self.green = green |
48 | 53 |
self.blue = blue |
49 | 54 |
|
55 |
|
|
50 | 56 |
''' |
51 | 57 |
@brief MessageType |
52 | 58 |
@author humkyung |
53 | 59 |
@date 2018.07.31 |
54 | 60 |
''' |
61 |
|
|
62 |
|
|
55 | 63 |
class MessageType(Enum): |
56 | 64 |
Normal = 1 |
57 | 65 |
Error = 2 |
58 | 66 |
|
67 |
|
|
59 | 68 |
class AppDocData(SingletonInstane): |
60 | 69 |
DATABASE = 'ITI_PID.db' |
70 |
|
|
61 | 71 |
def __init__(self): |
62 | 72 |
from DisplayColors import DisplayColors |
63 | 73 |
|
... | ... | |
109 | 119 |
@author humkyung |
110 | 120 |
@date 2018.09.06 |
111 | 121 |
''' |
122 |
|
|
112 | 123 |
def clear(self): |
113 | 124 |
self._imgFilePath = None |
114 | 125 |
self.imgName = None |
... | ... | |
136 | 147 |
@author euisung |
137 | 148 |
@date 2018.09.28 |
138 | 149 |
''' |
150 |
|
|
139 | 151 |
def getDrawingFileList(self): |
140 | 152 |
""" get drawing files which's extension is .png or jpg from drawing folder """ |
141 | 153 |
try: |
142 | 154 |
project = AppDocData.instance().getCurrentProject() |
143 | 155 |
path = project.getDrawingFilePath() |
144 |
drawingFileList = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and (os.path.splitext(f)[1] == '.png' or os.path.splitext(f)[1] == '.jpg' or os.path.splitext(f)[1] == '.jpeg' or os.path.splitext(f)[1] == '.JPEG' or os.path.splitext(f)[1] == '.PNG')] |
|
156 |
drawingFileList = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and ( |
|
157 |
os.path.splitext(f)[1] == '.png' or os.path.splitext(f)[1] == '.jpg' or os.path.splitext(f)[ |
|
158 |
1] == '.jpeg' or os.path.splitext(f)[1] == '.JPEG' or os.path.splitext(f)[1] == '.PNG')] |
|
145 | 159 |
drawingFileList.sort() |
146 | 160 |
except Exception as ex: |
147 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
161 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
162 |
sys.exc_info()[-1].tb_lineno)) |
|
148 | 163 |
|
149 | 164 |
return drawingFileList |
150 | 165 |
|
... | ... | |
153 | 168 |
@author euisung |
154 | 169 |
@date 2018.10.16 |
155 | 170 |
''' |
171 |
|
|
156 | 172 |
def getTrainingFileList(self): |
157 | 173 |
try: |
158 | 174 |
project = AppDocData.instance().getCurrentProject() |
... | ... | |
160 | 176 |
drawingFileList = os.listdir(path) |
161 | 177 |
drawingFileList.sort() |
162 | 178 |
except Exception as ex: |
163 |
from App import App |
|
164 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
179 |
from App import App |
|
180 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
181 |
sys.exc_info()[-1].tb_lineno) |
|
165 | 182 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
166 | 183 |
|
167 | 184 |
return drawingFileList |
... | ... | |
172 | 189 |
@date 2018.06.27 |
173 | 190 |
@history 2018.06.29 Jeongwoo Change method to get template db path |
174 | 191 |
''' |
192 |
|
|
175 | 193 |
def getTemplateDbPath(self): |
176 | 194 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
177 | 195 |
templateDbPath = os.path.join(path, 'Template.db') |
... | ... | |
186 | 204 |
|
187 | 205 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
188 | 206 |
app_database = os.path.join(path, 'App.db') |
189 |
return app_database
|
|
207 |
return app_database |
|
190 | 208 |
|
191 | 209 |
''' |
192 | 210 |
@brief getter of colors |
193 | 211 |
@author humkyung |
194 | 212 |
@date 2018.06.18 |
195 | 213 |
''' |
214 |
|
|
196 | 215 |
@property |
197 | 216 |
def colors(self): |
198 | 217 |
import random |
... | ... | |
210 | 229 |
self._colors.append(Color(int(row[0]), int(row[1]), int(row[2]), int(row[3]))) |
211 | 230 |
# Catch the exception |
212 | 231 |
except Exception as ex: |
213 |
from App import App |
|
214 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
232 |
from App import App |
|
233 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
234 |
sys.exc_info()[-1].tb_lineno) |
|
215 | 235 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
216 | 236 |
|
217 | 237 |
return self._colors.pop(random.randrange(0, len(self._colors))) |
... | ... | |
221 | 241 |
@author humkyung |
222 | 242 |
@date 2018.06.18 |
223 | 243 |
''' |
244 |
|
|
224 | 245 |
@colors.setter |
225 | 246 |
def colors(self, value): |
226 | 247 |
self._colors = value |
... | ... | |
230 | 251 |
@author humkyung |
231 | 252 |
@date 2018.07.30 |
232 | 253 |
''' |
254 |
|
|
233 | 255 |
def setImgFilePath(self, path): |
234 | 256 |
self._imgFilePath = path |
235 | 257 |
self.imgName = os.path.splitext(os.path.basename(self._imgFilePath))[0] |
... | ... | |
240 | 262 |
import numpy as np |
241 | 263 |
import cv2 |
242 | 264 |
|
243 |
stream = open(filePath.encode('utf-8') , 'rb')
|
|
265 |
stream = open(filePath.encode('utf-8'), 'rb') |
|
244 | 266 |
_bytes = bytearray(stream.read()) |
245 | 267 |
numpyArray = np.asarray(_bytes, dtype=np.uint8) |
246 | 268 |
return cv2.imdecode(numpyArray, cv2.IMREAD_UNCHANGED) |
... | ... | |
250 | 272 |
@author humkyung |
251 | 273 |
@date 2018.07.30 |
252 | 274 |
''' |
275 |
|
|
253 | 276 |
@property |
254 | 277 |
def imgSrc(self): |
255 | 278 |
import cv2 |
... | ... | |
257 | 280 |
|
258 | 281 |
if self._imgSrc is None and self._imgFilePath is not None and os.path.isfile(self._imgFilePath): |
259 | 282 |
self._imgSrc = cv2.cvtColor(AppDocData.my_imread(self._imgFilePath), cv2.COLOR_BGR2GRAY) |
260 |
kernel = np.array([[-1,-1,-1],
|
|
261 |
[-1, 9,-1],
|
|
262 |
[-1,-1,-1]])
|
|
283 |
kernel = np.array([[-1, -1, -1],
|
|
284 |
[-1, 9, -1],
|
|
285 |
[-1, -1, -1]])
|
|
263 | 286 |
self._imgSrc = cv2.filter2D(self._imgSrc, -1, kernel) |
264 |
#blur = cv2.GaussianBlur(self._imgSrc , (5,5), 0) |
|
265 |
#smooth = cv2.addWeighted(blur, 1.5, self._imgSrc, -0.5, 0) |
|
266 |
#self._imgSrc = cv2.threshold(smooth, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1] |
|
267 |
self._imgSrc = cv2.threshold(self._imgSrc, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1]
|
|
268 |
|
|
287 |
# blur = cv2.GaussianBlur(self._imgSrc , (5,5), 0)
|
|
288 |
# smooth = cv2.addWeighted(blur, 1.5, self._imgSrc, -0.5, 0)
|
|
289 |
# self._imgSrc = cv2.threshold(smooth, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)[1]
|
|
290 |
self._imgSrc = cv2.threshold(self._imgSrc, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
|
|
291 |
|
|
269 | 292 |
configs = AppDocData.instance().getConfigs('Filter', 'DilateSize') |
270 | 293 |
if 1 == len(configs) and int(configs[0].value) is not 0: |
271 | 294 |
size = int(configs[0].value) |
272 | 295 |
kernel = np.ones((size, size), np.uint8) |
273 | 296 |
self._imgSrc = cv2.erode(self._imgSrc, kernel, iterations=1) |
274 |
|
|
297 |
|
|
275 | 298 |
return self._imgSrc |
276 | 299 |
|
277 | 300 |
''' |
... | ... | |
279 | 302 |
@author humkyung |
280 | 303 |
@date 2018.07.30 |
281 | 304 |
''' |
305 |
|
|
282 | 306 |
@imgSrc.setter |
283 | 307 |
def imgSrc(self, value): |
284 | 308 |
self._imgSrc = value |
... | ... | |
288 | 312 |
@author humkyung |
289 | 313 |
@date 2018.07.30 |
290 | 314 |
''' |
315 |
|
|
291 | 316 |
def resetImgSrc(self): |
292 | 317 |
self._imgSrc = None |
293 | 318 |
|
... | ... | |
296 | 321 |
@author humkyung |
297 | 322 |
@date 2018.06.28 |
298 | 323 |
''' |
324 |
|
|
299 | 325 |
@property |
300 | 326 |
def lineTypeConfigs(self): |
301 | 327 |
from PyQt5.QtCore import Qt |
... | ... | |
303 | 329 |
if self._lineTypeConfigs is None: |
304 | 330 |
self._lineTypeConfigs = [] |
305 | 331 |
|
306 |
styleMap = [('SolidLine', Qt.SolidLine), ('DashLine', Qt.DashLine), ('DotLine', Qt.DotLine), ('DashDotLine', Qt.DashDotLine), |
|
307 |
('DashDotDotLine', Qt.DashDotDotLine), ('CustomDashLine', Qt.CustomDashLine)] |
|
332 |
styleMap = [('SolidLine', Qt.SolidLine), ('DashLine', Qt.DashLine), ('DotLine', Qt.DotLine), |
|
333 |
('DashDotLine', Qt.DashDotLine), |
|
334 |
('DashDotDotLine', Qt.DashDotDotLine), ('CustomDashLine', Qt.CustomDashLine)] |
|
308 | 335 |
|
309 | 336 |
configs = self.getConfigs('LineTypes') |
310 | 337 |
for config in configs: |
... | ... | |
312 | 339 |
matches = [param for param in styleMap if param[0] == _style] |
313 | 340 |
style = matches[0][1] if matches else Qt.SolidLine |
314 | 341 |
self._lineTypeConfigs.append((config.key, color, int(width), style, float(transparent))) |
315 |
|
|
342 |
|
|
316 | 343 |
return self._lineTypeConfigs |
317 | 344 |
|
318 | 345 |
''' |
... | ... | |
320 | 347 |
@author humkyung |
321 | 348 |
@date 2018.06.28 |
322 | 349 |
''' |
350 |
|
|
323 | 351 |
@lineTypeConfigs.setter |
324 | 352 |
def lineTypeConfigs(self, value): |
325 | 353 |
self._lineTypeConfigs = value |
... | ... | |
343 | 371 |
@author humkyung |
344 | 372 |
@date 2018.07.16 |
345 | 373 |
''' |
374 |
|
|
346 | 375 |
@property |
347 | 376 |
def hmbTable(self): |
348 | 377 |
from HMBTable import HMBTable |
... | ... | |
350 | 379 |
if self._hmbTable is None: |
351 | 380 |
self._hmbTable = HMBTable() |
352 | 381 |
self._hmbTable.loadData() |
353 |
|
|
382 |
|
|
354 | 383 |
return self._hmbTable |
355 | 384 |
|
356 | 385 |
''' |
... | ... | |
358 | 387 |
@author humkyung |
359 | 388 |
@date 2018.07.16 |
360 | 389 |
''' |
390 |
|
|
361 | 391 |
@hmbTable.setter |
362 | 392 |
def hmbTable(self, value): |
363 | 393 |
self._hmbTable = value |
... | ... | |
367 | 397 |
@author humkyung |
368 | 398 |
@date 2018.06.28 |
369 | 399 |
''' |
400 |
|
|
370 | 401 |
def getLineTypeConfig(self, lineType): |
371 | 402 |
from PyQt5.QtCore import Qt |
372 | 403 |
|
373 | 404 |
matches = [config for config in self.lineTypeConfigs if config[0] == lineType] |
374 |
return matches[0] if matches else (lineType, '#0000FF', 5, Qt.SolidLine, 50)
|
|
405 |
return matches[0] if matches else (lineType, '#0000FF', 5, Qt.SolidLine, 50) |
|
375 | 406 |
|
376 | 407 |
def getCurrentPidSource(self): |
377 | 408 |
return self.activeDrawing.currentPidSource |
... | ... | |
381 | 412 |
@author Jeongwoo |
382 | 413 |
@date 2018.05.03 |
383 | 414 |
''' |
415 |
|
|
384 | 416 |
def isExistFileName(self, name): |
385 | 417 |
rows = None |
386 | 418 |
conn = self.project.database.connect() |
387 | 419 |
with conn: |
388 | 420 |
try: |
389 | 421 |
cursor = conn.cursor() |
390 |
sql = "SELECT * FROM Symbol WHERE name = '"+ name +"'"
|
|
422 |
sql = "SELECT * FROM Symbol WHERE name = '" + name + "'"
|
|
391 | 423 |
cursor.execute(sql) |
392 | 424 |
rows = cursor.fetchall() |
393 | 425 |
# Catch the exception |
394 | 426 |
except Exception as ex: |
395 | 427 |
# Roll back any change if something goes wrong |
396 | 428 |
conn.rollback() |
397 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
429 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
430 |
sys.exc_info()[-1].tb_lineno)) |
|
398 | 431 |
finally: |
399 | 432 |
if rows is not None and len(rows) > 0: |
400 | 433 |
return True |
... | ... | |
406 | 439 |
@author Jeongwoo |
407 | 440 |
@date 2018.05.03 |
408 | 441 |
''' |
442 |
|
|
409 | 443 |
def insertSymbol(self, symbol): |
410 | 444 |
isAdded = False |
411 | 445 |
conn = self.project.database.connect() |
... | ... | |
417 | 451 |
""") |
418 | 452 |
|
419 | 453 |
cursor = conn.cursor() |
420 |
query = ( symbol.getName(), symbol.getType(), symbol.getThreshold() |
|
421 |
, symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount() |
|
422 |
, symbol.getOcrOption(), symbol.getIsContainChild() |
|
423 |
, symbol.getOriginalPoint(), symbol.getConnectionPoint() |
|
424 |
, symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), symbol.getHasInstrumentLabel() |
|
425 |
, symbol.width, symbol.height, symbol.detectFlip) |
|
454 |
query = (symbol.getName(), symbol.getType(), symbol.getThreshold() |
|
455 |
, symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount() |
|
456 |
, symbol.getOcrOption(), symbol.getIsContainChild() |
|
457 |
, symbol.getOriginalPoint(), symbol.getConnectionPoint() |
|
458 |
, symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), |
|
459 |
symbol.getHasInstrumentLabel() |
|
460 |
, symbol.width, symbol.height, symbol.detectFlip) |
|
426 | 461 |
cursor.execute(sql, query) |
427 | 462 |
conn.commit() |
428 | 463 |
isAdded = True |
... | ... | |
431 | 466 |
# Roll back any change if something goes wrong |
432 | 467 |
conn.rollback() |
433 | 468 |
|
434 |
from App import App |
|
435 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
469 |
from App import App |
|
470 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
471 |
sys.exc_info()[-1].tb_lineno) |
|
436 | 472 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
437 | 473 |
finally: |
438 | 474 |
return (isAdded, symbol.getType(), symbol.getName(), symbol.getPath()) |
... | ... | |
442 | 478 |
@author Jeongwoo |
443 | 479 |
@date 2018.05.03 |
444 | 480 |
''' |
481 |
|
|
445 | 482 |
def updateSymbol(self, symbol): |
446 | 483 |
isUpdated = False |
447 | 484 |
|
... | ... | |
456 | 493 |
baseSymbol = ?, additionalSymbol = ?, isExceptDetect = ?, hasInstrumentLabel = ?, width = ?, height = ?, flip = ? |
457 | 494 |
WHERE uid = ? |
458 | 495 |
""") |
459 |
|
|
496 |
|
|
460 | 497 |
cursor = conn.cursor() |
461 | 498 |
query = (symbol.getName(), symbol.getType(), symbol.getThreshold() |
462 |
, symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount() |
|
463 |
, symbol.getOcrOption(), symbol.getIsContainChild() |
|
464 |
, symbol.getOriginalPoint(), symbol.getConnectionPoint() |
|
465 |
, symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), symbol.getHasInstrumentLabel(), symbol.width, symbol.height, symbol.detectFlip, symbol.getUid()) |
|
499 |
, symbol.getMinMatchCount(), symbol.getIsDetectOnOrigin(), symbol.getRotationCount() |
|
500 |
, symbol.getOcrOption(), symbol.getIsContainChild() |
|
501 |
, symbol.getOriginalPoint(), symbol.getConnectionPoint() |
|
502 |
, symbol.getBaseSymbol(), symbol.getAdditionalSymbol(), symbol.getIsExceptDetect(), |
|
503 |
symbol.getHasInstrumentLabel(), symbol.width, symbol.height, symbol.detectFlip, |
|
504 |
symbol.getUid()) |
|
466 | 505 |
cursor.execute(sql, query) |
467 | 506 |
conn.commit() |
468 | 507 |
isUpdated = True |
... | ... | |
471 | 510 |
# Roll back any change if something goes wrong |
472 | 511 |
conn.rollback() |
473 | 512 |
|
474 |
from App import App |
|
475 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
513 |
from App import App |
|
514 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
515 |
sys.exc_info()[-1].tb_lineno) |
|
476 | 516 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
477 | 517 |
finally: |
478 | 518 |
return (isUpdated, symbol.getType(), symbol.getName(), symbol.getPath()) |
... | ... | |
483 | 523 |
@date 18.04.24 |
484 | 524 |
@history humkyung 2018.06.28 select symbol order by threshold descending |
485 | 525 |
''' |
526 |
|
|
486 | 527 |
def getTargetSymbolList(self): |
487 | 528 |
targetSymbolList = [] |
488 | 529 |
|
... | ... | |
495 | 536 |
cursor.execute(sql) |
496 | 537 |
rows = cursor.fetchall() |
497 | 538 |
for row in rows: |
498 |
sym = symbol.SymbolBase(row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10], row[11], row[12], row[13], row[14], row[0], detectFlip=row[15]) ## uid is last item |
|
539 |
sym = symbol.SymbolBase(row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], |
|
540 |
row[10], row[11], row[12], row[13], row[14], row[0], |
|
541 |
detectFlip=row[15]) ## uid is last item |
|
499 | 542 |
targetSymbolList.append(sym) |
500 | 543 |
except Exception as ex: |
501 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
544 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
545 |
sys.exc_info()[-1].tb_lineno)) |
|
502 | 546 |
|
503 | 547 |
return targetSymbolList |
504 | 548 |
|
... | ... | |
507 | 551 |
@author humkyung |
508 | 552 |
@date 2018.04.20 |
509 | 553 |
''' |
554 |
|
|
510 | 555 |
def buildAppDatabase(self): |
511 | 556 |
try: |
512 | 557 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
... | ... | |
533 | 578 |
except Exception as ex: |
534 | 579 |
# Roll back any change if something goes wrong |
535 | 580 |
conn.rollback() |
536 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
581 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
582 |
sys.exc_info()[-1].tb_lineno)) |
|
537 | 583 |
finally: |
538 | 584 |
# Close the db connection |
539 | 585 |
conn.close() |
... | ... | |
546 | 592 |
@author humkyung |
547 | 593 |
@date 2018.04.20 |
548 | 594 |
''' |
595 |
|
|
549 | 596 |
def loadAppStyle(self): |
550 | 597 |
style = 'Fusion' |
551 | 598 |
|
... | ... | |
560 | 607 |
# Get a cursor object |
561 | 608 |
cursor = conn.cursor() |
562 | 609 |
|
563 |
sql = "select Value from Configuration where Section='App' and Key='Style'"
|
|
610 |
sql = "select Value from Configuration where Section='App' and Key='Style'" |
|
564 | 611 |
cursor.execute(sql) |
565 | 612 |
rows = cursor.fetchall() |
566 | 613 |
style = rows[0][0] if 1 == len(rows) else 'Fusion' |
... | ... | |
568 | 615 |
except Exception as ex: |
569 | 616 |
# Roll back any change if something goes wrong |
570 | 617 |
conn.rollback() |
571 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
618 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
619 |
sys.exc_info()[-1].tb_lineno)) |
|
572 | 620 |
finally: |
573 | 621 |
# Close the db connection |
574 | 622 |
conn.close() |
... | ... | |
580 | 628 |
@author humkyung |
581 | 629 |
@date 2018.04.20 |
582 | 630 |
''' |
631 |
|
|
583 | 632 |
def loadAppStyles(self): |
584 | 633 |
styles = [] |
585 | 634 |
|
... | ... | |
603 | 652 |
except Exception as ex: |
604 | 653 |
# Roll back any change if something goes wrong |
605 | 654 |
conn.rollback() |
606 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
655 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
656 |
sys.exc_info()[-1].tb_lineno)) |
|
607 | 657 |
finally: |
608 | 658 |
# Close the db connection |
609 | 659 |
conn.close() |
... | ... | |
614 | 664 |
@brief Set current Project |
615 | 665 |
@history 2018.06.27 Jeongwoo If DB file is not, copy DB file from ProgramData |
616 | 666 |
''' |
667 |
|
|
617 | 668 |
def setCurrentProject(self, project): |
618 | 669 |
self.project = project |
619 | 670 |
self.makeChildDir() |
... | ... | |
621 | 672 |
if self.project.database.db_type == 'SQLite': |
622 | 673 |
# Creates or opens a file called mydb with a SQLite3 DB |
623 | 674 |
db_path = self.project.database.file_path |
624 |
|
|
675 |
|
|
625 | 676 |
if not os.path.isfile(db_path): |
626 | 677 |
templatePath = self.getTemplateDbPath() |
627 | 678 |
templateFile = QFile(templatePath) |
... | ... | |
637 | 688 |
for fileName in fileNames: |
638 | 689 |
if fileName.endswith(".sql") and (1 == len(os.path.splitext(fileName)[0].split('.'))): |
639 | 690 |
try: |
640 |
file = QFile(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Scripts', fileName)) |
|
691 |
file = QFile( |
|
692 |
os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Scripts', fileName)) |
|
641 | 693 |
file.open(QFile.ReadOnly) |
642 | 694 |
sql = file.readAll() |
643 | 695 |
sql = str(sql, encoding='utf8') |
... | ... | |
646 | 698 |
file.close() |
647 | 699 |
conn.commit() |
648 | 700 |
except Exception as ex: |
649 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
701 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
702 |
sys.exc_info()[-1].tb_lineno)) |
|
650 | 703 |
# Catch the exception |
651 | 704 |
except Exception as ex: |
652 | 705 |
# Roll back any change if something goes wrong |
653 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
706 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
707 |
sys.exc_info()[-1].tb_lineno)) |
|
654 | 708 |
finally: |
655 | 709 |
pass |
656 | 710 |
|
... | ... | |
662 | 716 |
humkyung 2018.07.09 make drawing folder if not exists |
663 | 717 |
euisung 2018.09.28 make training folder if not exists |
664 | 718 |
''' |
719 |
|
|
665 | 720 |
def makeChildDir(self): |
666 | 721 |
project = AppDocData.instance().getCurrentProject() |
667 | 722 |
dbDir = project.getDbFilePath() |
... | ... | |
685 | 740 |
trainingPath = project.getTrainingFilePath() |
686 | 741 |
if not os.path.exists(trainingPath): |
687 | 742 |
os.makedirs(trainingPath) |
688 |
|
|
743 |
|
|
689 | 744 |
path = os.path.join(tempDir, 'Tile') |
690 | 745 |
if not os.path.exists(path): |
691 | 746 |
os.makedirs(path) |
... | ... | |
696 | 751 |
''' |
697 | 752 |
@brief Get current Project |
698 | 753 |
''' |
754 |
|
|
699 | 755 |
def getCurrentProject(self): |
700 | 756 |
return self.project |
701 | 757 |
|
... | ... | |
703 | 759 |
@brief return project database path |
704 | 760 |
@history humkyung 2018.04.19 return Project.db in Program Data folder instead of PROJECT_DB_PATH variable |
705 | 761 |
''' |
762 |
|
|
706 | 763 |
def getPrjDatabasePath(self): |
707 | 764 |
path = os.path.join(os.getenv('ALLUSERSPROFILE'), 'Digital PID') |
708 | 765 |
if not os.path.exists(path): os.makedirs(path) |
... | ... | |
728 | 785 |
except Exception as ex: |
729 | 786 |
# Roll back any change if something goes wrong |
730 | 787 |
conn.rollback() |
731 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
788 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
789 |
sys.exc_info()[-1].tb_lineno)) |
|
732 | 790 |
finally: |
733 | 791 |
# Close the db connection |
734 | 792 |
conn.close() |
735 |
|
|
793 |
|
|
736 | 794 |
return prjDatabaseFilePath |
737 | 795 |
|
738 | 796 |
def getErrorItemSvgPath(self): |
... | ... | |
760 | 818 |
if originTitleBlockProp[0] == titleBlockProp[0]: |
761 | 819 |
break |
762 | 820 |
deletedTitleBlockProps.append(originTitleBlockProp[0]) |
763 |
|
|
821 |
|
|
764 | 822 |
# Creates or opens a file called mydb with a SQLite3 DB |
765 | 823 |
conn = self.project.database.connect() |
766 | 824 |
with conn: |
... | ... | |
773 | 831 |
cursor.execute(sql) |
774 | 832 |
|
775 | 833 |
for titleBlockProp in titleBlockProps: |
776 |
sql = "insert or replace into TitleBlockProperties values(?,?,?)"
|
|
777 |
param = (titleBlockProp[0], titleBlockProp[1], titleBlockProp[2]) # uid, name, area |
|
834 |
sql = "insert into TitleBlockProperties values(?,?,?)" |
|
835 |
param = (titleBlockProp[0], titleBlockProp[1], titleBlockProp[2]) # uid, name, area
|
|
778 | 836 |
cursor.execute(sql, param) |
779 | 837 |
conn.commit() |
780 | 838 |
# Catch the exception |
781 | 839 |
except Exception as ex: |
782 | 840 |
# Roll back any change if something goes wrong |
783 | 841 |
conn.rollback() |
784 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
842 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
843 |
sys.exc_info()[-1].tb_lineno)) |
|
785 | 844 |
# Catch the exception |
786 | 845 |
except Exception as ex: |
787 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
846 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
847 |
sys.exc_info()[-1].tb_lineno)) |
|
788 | 848 |
|
789 | 849 |
self._titleBlockProperties = None |
790 |
|
|
850 |
|
|
791 | 851 |
def getTitleBlockProperties(self): |
792 | 852 |
''' |
793 | 853 |
@brief return title block properties |
... | ... | |
795 | 855 |
@date 2018.11.09 |
796 | 856 |
''' |
797 | 857 |
res = None |
798 |
if True:#self._titleBlockProperties is None:
|
|
858 |
if True: # self._titleBlockProperties is None:
|
|
799 | 859 |
self._titleBlockProperties = [] |
800 | 860 |
|
801 | 861 |
# Creates or opens a file called mydb with a SQLite3 DB |
... | ... | |
805 | 865 |
# Get a cursor object |
806 | 866 |
cursor = conn.cursor() |
807 | 867 |
|
808 |
sql = "select UID, Name, AREA from TitleBlockProperties"
|
|
868 |
sql = "select UID, Name, AREA from TitleBlockProperties" |
|
809 | 869 |
cursor.execute(sql) |
810 | 870 |
rows = cursor.fetchall() |
811 | 871 |
for row in rows: |
... | ... | |
813 | 873 |
continue |
814 | 874 |
else: |
815 | 875 |
attr = [] |
816 |
attr.append(row[0]) # uid |
|
817 |
attr.append(row[1].split('!@!')[1]) # name |
|
818 |
attr.append(row[2]) # area |
|
876 |
attr.append(row[0]) # uid
|
|
877 |
attr.append(row[1].split('!@!')[1]) # name
|
|
878 |
attr.append(row[2]) # area
|
|
819 | 879 |
self._titleBlockProperties.append(attr) |
820 |
|
|
880 |
|
|
821 | 881 |
res = self._titleBlockProperties |
822 | 882 |
# Catch the exception |
823 | 883 |
except Exception as ex: |
824 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
884 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
885 |
sys.exc_info()[-1].tb_lineno)) |
|
825 | 886 |
else: |
826 | 887 |
res = self._titleBlockProperties |
827 | 888 |
|
... | ... | |
835 | 896 |
@author humkyung |
836 | 897 |
@date 2018.04.09 |
837 | 898 |
''' |
899 |
|
|
838 | 900 |
def getLineProperties(self): |
839 | 901 |
from SymbolAttr import SymbolAttr |
840 | 902 |
|
... | ... | |
848 | 910 |
# Get a cursor object |
849 | 911 |
cursor = conn.cursor() |
850 | 912 |
|
851 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]"
|
|
913 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties order by [index]" |
|
852 | 914 |
cursor.execute(sql) |
853 | 915 |
rows = cursor.fetchall() |
854 | 916 |
for row in rows: |
... | ... | |
859 | 921 |
attr.AttributeType = row[3] |
860 | 922 |
attr.Length = row[4] |
861 | 923 |
self._lineNoProperties.append(attr) |
862 |
|
|
924 |
|
|
863 | 925 |
res = self._lineNoProperties |
864 | 926 |
# Catch the exception |
865 | 927 |
except Exception as ex: |
866 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
928 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
929 |
sys.exc_info()[-1].tb_lineno)) |
|
867 | 930 |
else: |
868 | 931 |
res = self._lineNoProperties |
869 | 932 |
|
... | ... | |
874 | 937 |
@author humkyung |
875 | 938 |
@date 2018.04.09 |
876 | 939 |
''' |
940 |
|
|
877 | 941 |
def getLinePropertiesByUID(self, UID): |
878 | 942 |
from SymbolAttr import SymbolAttr |
879 | 943 |
|
... | ... | |
884 | 948 |
# Get a cursor object |
885 | 949 |
cursor = conn.cursor() |
886 | 950 |
|
887 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties where uid = '{}'".format(UID) |
|
951 |
sql = "select UID, Name, DisplayName, Type, LimitNumber, [index] from LineProperties where uid = '{}'".format( |
|
952 |
UID) |
|
888 | 953 |
cursor.execute(sql) |
889 | 954 |
rows = cursor.fetchall() |
890 | 955 |
for row in rows: |
... | ... | |
897 | 962 |
res.append(attr) |
898 | 963 |
# Catch the exception |
899 | 964 |
except Exception as ex: |
900 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
965 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
966 |
sys.exc_info()[-1].tb_lineno)) |
|
901 | 967 |
|
902 | 968 |
return res |
903 | 969 |
|
... | ... | |
906 | 972 |
@author humkyung |
907 | 973 |
@date 2018.06.27 |
908 | 974 |
''' |
975 |
|
|
909 | 976 |
def getLineTypes(self): |
910 | 977 |
from LineTypeConditions import LineTypeConditions |
911 | 978 |
|
... | ... | |
914 | 981 |
with conn: |
915 | 982 |
try: |
916 | 983 |
cursor = conn.cursor() if self.project.database.db_type == 'SQLite' else conn.cursor(as_dict=True) |
917 |
sql = "select UID,Name,Type1,Conditions1,Type2,Conditions2 from LineTypes order by Name"
|
|
984 |
sql = "select UID,Name,Type1,Conditions1,Type2,Conditions2 from LineTypes order by Name" |
|
918 | 985 |
cursor.execute(sql) |
919 | 986 |
rows = cursor.fetchall() |
920 | 987 |
for row in rows: |
... | ... | |
926 | 993 |
res.append(line_type) |
927 | 994 |
# Catch the exception |
928 | 995 |
except Exception as ex: |
929 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
996 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
997 |
sys.exc_info()[-1].tb_lineno)) |
|
930 | 998 |
|
931 | 999 |
return res |
932 | 1000 |
|
... | ... | |
936 | 1004 |
@date 2018.04.06 |
937 | 1005 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable |
938 | 1006 |
''' |
1007 |
|
|
939 | 1008 |
def insertProjectInfo(self, desc, prj_unit, dir): |
940 | 1009 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
941 | 1010 |
conn = sqlite3.connect(prjDatabaseFilePath) |
... | ... | |
946 | 1015 |
nowDate = datetime.datetime.now().strftime('%Y.%m.%d %H:%M') |
947 | 1016 |
sql = "insert or replace into Projects(Name, [Desc], [Unit], Path, CreatedDate, UpdatedDate) values(?, ?, ?, ?, ?, ?)" |
948 | 1017 |
param = (folderName, desc, prj_unit, dir, nowDate, nowDate) |
949 |
|
|
1018 |
|
|
950 | 1019 |
cursor = conn.cursor() |
951 | 1020 |
cursor.execute(sql, param) |
952 | 1021 |
conn.commit() |
... | ... | |
955 | 1024 |
except Exception as ex: |
956 | 1025 |
# Roll back any change if something goes wrong |
957 | 1026 |
conn.rollback() |
958 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1027 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1028 |
sys.exc_info()[-1].tb_lineno)) |
|
959 | 1029 |
|
960 | 1030 |
def removeProjectInfo(self, targetProject): |
961 | 1031 |
''' |
... | ... | |
974 | 1044 |
except Exception as ex: |
975 | 1045 |
# Roll back any change if something goes wrong |
976 | 1046 |
conn.rollback() |
977 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1047 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1048 |
sys.exc_info()[-1].tb_lineno)) |
|
978 | 1049 |
|
979 | 1050 |
''' |
980 | 1051 |
@brief update project |
... | ... | |
982 | 1053 |
@date 2018.04.06 |
983 | 1054 |
@history humkyung 2018.04.19 use getPrjDatabasePath function instead of PROJECT_DB_PATH variable |
984 | 1055 |
''' |
1056 |
|
|
985 | 1057 |
def updateProjectUpdatedDate(self, project): |
986 | 1058 |
prjDatabaseFilePath = self.getPrjDatabasePath() |
987 | 1059 |
conn = sqlite3.connect(prjDatabaseFilePath) |
... | ... | |
998 | 1070 |
|
999 | 1071 |
sql = 'insert or replace into DBSettings(Projects_UID, DBTypes_UID, Host, User, Password, FilePath) values(?,(select UID from DBTypes where Name=?),?,?,?,?)' |
1000 | 1072 |
cur = conn.cursor() |
1001 |
cur.execute(sql, (project.getId(), project.database.db_type, project.database.host, project.database.user, project.database.password, project.database.file_path)) |
|
1073 |
cur.execute(sql, ( |
|
1074 |
project.getId(), project.database.db_type, project.database.host, project.database.user, |
|
1075 |
project.database.password, project.database.file_path)) |
|
1002 | 1076 |
conn.commit() |
1003 | 1077 |
except Exception as ex: |
1004 | 1078 |
# Roll back any change if something goes wrong |
1005 | 1079 |
conn.rollback() |
1006 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1080 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1081 |
sys.exc_info()[-1].tb_lineno)) |
|
1007 | 1082 |
|
1008 | 1083 |
''' |
1009 | 1084 |
@brief get project list from database |
1010 | 1085 |
@history humkyung 2018.04.18 add only project which's project exists |
1011 | 1086 |
''' |
1087 |
|
|
1012 | 1088 |
def getProjectList(self): |
1013 | 1089 |
from Project import Project |
1014 | 1090 |
|
... | ... | |
1030 | 1106 |
cursor.execute(sql) |
1031 | 1107 |
rows = cursor.fetchall() |
1032 | 1108 |
for row in rows: |
1033 |
if os.path.isdir(row['Path']): # check if folder exists
|
|
1109 |
if os.path.isdir(row['Path']): # check if folder exists |
|
1034 | 1110 |
projectList.append(Project(row)) |
1035 | 1111 |
except Exception as ex: |
1036 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1112 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1113 |
sys.exc_info()[-1].tb_lineno)) |
|
1037 | 1114 |
|
1038 | 1115 |
return projectList |
1039 | 1116 |
|
... | ... | |
1041 | 1118 |
@brief get sliding window size |
1042 | 1119 |
@author humkyung |
1043 | 1120 |
''' |
1121 |
|
|
1044 | 1122 |
def getSlidingWindowSize(self): |
1045 |
res = [25,20] |
|
1123 |
res = [25, 20]
|
|
1046 | 1124 |
try: |
1047 | 1125 |
configs = self.getConfigs('Sliding Window') |
1048 | 1126 |
for config in configs: |
... | ... | |
1052 | 1130 |
res[1] = int(config.value) |
1053 | 1131 |
# Catch the exception |
1054 | 1132 |
except Exception as ex: |
1055 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1056 |
|
|
1133 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1134 |
sys.exc_info()[-1].tb_lineno)) |
|
1135 |
|
|
1057 | 1136 |
return res |
1058 | 1137 |
|
1059 | 1138 |
''' |
... | ... | |
1061 | 1140 |
@author humkyung |
1062 | 1141 |
@date 2018.04.16 |
1063 | 1142 |
''' |
1143 |
|
|
1064 | 1144 |
def getLineNoConfiguration(self): |
1065 | 1145 |
res = None |
1066 | 1146 |
|
... | ... | |
1085 | 1165 |
res = rows[0][2].split(delimiter) |
1086 | 1166 |
# Catch the exception |
1087 | 1167 |
except Exception as ex: |
1088 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1089 |
|
|
1168 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1169 |
sys.exc_info()[-1].tb_lineno)) |
|
1170 |
|
|
1090 | 1171 |
return res |
1091 | 1172 |
|
1092 | 1173 |
''' |
... | ... | |
1094 | 1175 |
@author humkyung |
1095 | 1176 |
@history euisung 2018.11.20 (0,0),(0,0) process add |
1096 | 1177 |
''' |
1178 |
|
|
1097 | 1179 |
def getAreaList(self): |
1098 | 1180 |
from Area import Area |
1099 | 1181 |
|
... | ... | |
1114 | 1196 |
self._areas.append(area) |
1115 | 1197 |
# Catch the exception |
1116 | 1198 |
except Exception as ex: |
1117 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1118 |
|
|
1119 |
return self._areas |
|
1199 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1200 |
sys.exc_info()[-1].tb_lineno)) |
|
1201 |
|
|
1202 |
return self._areas |
|
1120 | 1203 |
|
1121 | 1204 |
''' |
1122 | 1205 |
@brief get area of given name |
1123 | 1206 |
@author humkyung |
1124 | 1207 |
@date 2018.04.07 |
1125 | 1208 |
''' |
1209 |
|
|
1126 | 1210 |
def getArea(self, name): |
1127 | 1211 |
areas = self.getAreaList() |
1128 |
matches = [area for area in areas if area.name==name]
|
|
1212 |
matches = [area for area in areas if area.name == name]
|
|
1129 | 1213 |
if 1 == len(matches) and matches[0].height is not 0 and matches[0].width is not 0: |
1130 | 1214 |
return matches[0] |
1131 | 1215 |
|
... | ... | |
1144 | 1228 |
cursor = conn.cursor() |
1145 | 1229 |
|
1146 | 1230 |
sql = "select * from configuration" |
1147 |
|
|
1231 |
|
|
1148 | 1232 |
cursor.execute(sql) |
1149 | 1233 |
rows = cursor.fetchall() |
1150 | 1234 |
for row in rows: |
1151 | 1235 |
self._configs.append(Config(row[0], row[1], row[2])) |
1152 | 1236 |
# Catch the exception |
1153 | 1237 |
except Exception as ex: |
1154 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1238 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1239 |
sys.exc_info()[-1].tb_lineno)) |
|
1155 | 1240 |
|
1156 | 1241 |
if key is not None: |
1157 | 1242 |
return [con for con in self._configs if con.section == section and con.key == key] |
... | ... | |
1190 | 1275 |
res.append(Config(row[0], row[1], row[2])) |
1191 | 1276 |
# Catch the exception |
1192 | 1277 |
except Exception as ex: |
1193 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1278 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1279 |
sys.exc_info()[-1].tb_lineno)) |
|
1194 | 1280 |
|
1195 | 1281 |
return res |
1196 | 1282 |
|
... | ... | |
1201 | 1287 |
@history humkyung 2018.07.03 replace ' with " if value has ' |
1202 | 1288 |
kyouho 2018.07.09 change query method |
1203 | 1289 |
''' |
1290 |
|
|
1204 | 1291 |
def saveConfigs(self, configs): |
1205 | 1292 |
conn = self.project.database.connect() |
1206 | 1293 |
with conn: |
... | ... | |
1214 | 1301 |
if type(value) is str and "'" in value: |
1215 | 1302 |
value = value.replace("'", "''") |
1216 | 1303 |
|
1217 |
sql = self.project.database.to_sql("insert into configuration(Section,[Key],Value) select ?,?,? where not exists(select 1 from configuration where Section=? and [Key]=?)") |
|
1304 |
sql = self.project.database.to_sql( |
|
1305 |
"insert into configuration(Section,[Key],Value) select ?,?,? where not exists(select 1 from configuration where Section=? and [Key]=?)") |
|
1218 | 1306 |
param = (config.section, config.key, str(value), config.section, config.key) |
1219 | 1307 |
cursor.execute(sql, param) |
1220 |
sql = self.project.database.to_sql("update configuration set Value=? where Section=? and [Key]=?") |
|
1308 |
sql = self.project.database.to_sql( |
|
1309 |
"update configuration set Value=? where Section=? and [Key]=?") |
|
1221 | 1310 |
param = (str(value), config.section, config.key) |
1222 | 1311 |
cursor.execute(sql, param) |
1223 | 1312 |
elif hasattr(config, 'toSql'): |
... | ... | |
1229 | 1318 |
else: |
1230 | 1319 |
if sql is not None and 2 == len(sql): |
1231 | 1320 |
cursor.execute(self.project.database.to_sql(sql[0]), sql[1]) |
1232 |
self._configs = None # reset config table |
|
1321 |
self._configs = None # reset config table
|
|
1233 | 1322 |
conn.commit() |
1234 | 1323 |
# Catch the exception |
1235 | 1324 |
except Exception as ex: |
1236 | 1325 |
# Roll back any change if something goes wrong |
1237 | 1326 |
conn.rollback() |
1238 | 1327 |
|
1239 |
from App import App |
|
1240 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1328 |
from App import App |
|
1329 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1330 |
sys.exc_info()[-1].tb_lineno) |
|
1241 | 1331 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1242 | 1332 |
|
1243 | 1333 |
def saveAppConfigs(self, configs): |
... | ... | |
1269 | 1359 |
except Exception as ex: |
1270 | 1360 |
# Roll back any change if something goes wrong |
1271 | 1361 |
conn.rollback() |
1272 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1362 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1363 |
sys.exc_info()[-1].tb_lineno)) |
|
1273 | 1364 |
|
1274 | 1365 |
''' |
1275 | 1366 |
@brief delete configurations |
1276 | 1367 |
@author humkyung |
1277 | 1368 |
@date 2018.06.29 |
1278 | 1369 |
''' |
1370 |
|
|
1279 | 1371 |
def deleteConfigs(self, section, key=None): |
1280 | 1372 |
conn = self.project.database.connect() |
1281 | 1373 |
with conn: |
... | ... | |
1294 | 1386 |
except Exception as ex: |
1295 | 1387 |
# Roll back any change if something goes wrong |
1296 | 1388 |
conn.rollback() |
1297 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1389 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1390 |
sys.exc_info()[-1].tb_lineno)) |
|
1298 | 1391 |
|
1299 | 1392 |
def deleteAppConfigs(self, section, key=None): |
1300 | 1393 |
""" |
... | ... | |
1322 | 1415 |
except Exception as ex: |
1323 | 1416 |
# Roll back any change if something goes wrong |
1324 | 1417 |
conn.rollback() |
1325 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1418 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1419 |
sys.exc_info()[-1].tb_lineno)) |
|
1326 | 1420 |
|
1327 | 1421 |
''' |
1328 | 1422 |
@brief set area list |
1329 | 1423 |
@history humkyung 2018.05.18 round area coordinate and dimension before saving |
1330 | 1424 |
@history euisung 2018.11.20 add self._area reset process |
1331 | 1425 |
''' |
1426 |
|
|
1332 | 1427 |
def setAreaList(self, areas): |
1333 | 1428 |
for area in areas: |
1334 |
matches = [x for x in self._areas if x.name==area.name]
|
|
1429 |
matches = [x for x in self._areas if x.name == area.name]
|
|
1335 | 1430 |
if 1 == len(matches): |
1336 | 1431 |
matches[0].x = area.x |
1337 | 1432 |
matches[0].y = area.y |
... | ... | |
1351 | 1446 |
sql = "insert into configuration select 'Area','{}','({},{}),({},{})' where not exists(select 1 from configuration where Section='Area' and [Key]='{}')".format( |
1352 | 1447 |
area.name, round(area.x), round(area.y), round(area.width), round(area.height), area.name) |
1353 | 1448 |
cursor.execute(sql) |
1354 |
sql = "update configuration set Value='({},{}),({},{})' where Section='Area' and [Key]='{}'".format(round(area.x), round(area.y), round(area.width), round(area.height), area.name) |
|
1449 |
sql = "update configuration set Value='({},{}),({},{})' where Section='Area' and [Key]='{}'".format( |
|
1450 |
round(area.x), round(area.y), round(area.width), round(area.height), area.name) |
|
1355 | 1451 |
cursor.execute(sql) |
1356 | 1452 |
conn.commit() |
1357 | 1453 |
# Catch the exception |
... | ... | |
1359 | 1455 |
# Roll back any change if something goes wrong |
1360 | 1456 |
conn.rollback() |
1361 | 1457 |
|
1362 |
from App import App |
|
1363 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1458 |
from App import App |
|
1459 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1460 |
sys.exc_info()[-1].tb_lineno) |
|
1364 | 1461 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1365 | 1462 |
finally: |
1366 | 1463 |
# Close the db connection |
1367 | 1464 |
self._areas = [] |
1368 |
|
|
1465 |
|
|
1369 | 1466 |
def getSymbolNameList(self): |
1370 | 1467 |
""" get symbol name list """ |
1371 | 1468 |
symbolNametList = [] |
... | ... | |
1378 | 1475 |
cursor.execute(sql) |
1379 | 1476 |
rows = cursor.fetchall() |
1380 | 1477 |
for row in rows: |
1381 |
symbolNametList.append(row[4]) # Name String |
|
1478 |
symbolNametList.append(row[4]) # Name String
|
|
1382 | 1479 |
except Exception as ex: |
1383 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1480 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1481 |
sys.exc_info()[-1].tb_lineno)) |
|
1384 | 1482 |
|
1385 | 1483 |
return symbolNametList |
1386 | 1484 |
|
... | ... | |
1390 | 1488 |
@date 18.04.06 |
1391 | 1489 |
@history . |
1392 | 1490 |
''' |
1491 |
|
|
1393 | 1492 |
def getSymbolNameListByType(self, type): |
1394 | 1493 |
symbolNametList = [] |
1395 | 1494 |
|
... | ... | |
1403 | 1502 |
cursor.execute(sql, (type,)) |
1404 | 1503 |
rows = cursor.fetchall() |
1405 | 1504 |
for row in rows: |
1406 |
symbolNametList.append(row[4]) # Name String |
|
1505 |
symbolNametList.append(row[4]) # Name String
|
|
1407 | 1506 |
except Exception as ex: |
1408 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1507 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1508 |
sys.exc_info()[-1].tb_lineno)) |
|
1409 | 1509 |
|
1410 | 1510 |
return symbolNametList |
1411 | 1511 |
|
1412 | 1512 |
''' |
1413 | 1513 |
@brief delete added symbol data |
1414 | 1514 |
''' |
1515 |
|
|
1415 | 1516 |
def deleteSymbol(self, fileName): |
1416 | 1517 |
ret = False |
1417 | 1518 |
|
... | ... | |
1426 | 1527 |
ret = True |
1427 | 1528 |
except Exception as ex: |
1428 | 1529 |
conn.rollback() |
1429 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1530 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1531 |
sys.exc_info()[-1].tb_lineno)) |
|
1430 | 1532 |
ret = False |
1431 | 1533 |
finally: |
1432 | 1534 |
return (ret, fileName) |
1433 |
|
|
1535 |
|
|
1434 | 1536 |
''' |
1435 | 1537 |
@brief get symbol name |
1436 | 1538 |
@history 18.04.24 Jeongwoo Add isExceptDetect Field |
1437 | 1539 |
''' |
1540 |
|
|
1438 | 1541 |
def getSymbolByQuery(self, fieldName, param): |
1439 | 1542 |
ret = None |
1440 | 1543 |
|
... | ... | |
1449 | 1552 |
if rows is not None and len(rows) > 0: |
1450 | 1553 |
symbolTuple = rows[0] |
1451 | 1554 |
ret = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3] |
1452 |
, symbolTuple[4], symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8] |
|
1453 |
, symbolTuple[9], symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0], detectFlip=symbolTuple[15]) ## uid is last item |
|
1555 |
, symbolTuple[4], symbolTuple[5], symbolTuple[6], symbolTuple[7], |
|
1556 |
symbolTuple[8] |
|
1557 |
, symbolTuple[9], symbolTuple[10], symbolTuple[11], symbolTuple[12], |
|
1558 |
symbolTuple[13], symbolTuple[14], symbolTuple[0], |
|
1559 |
detectFlip=symbolTuple[15]) ## uid is last item |
|
1454 | 1560 |
except Exception as ex: |
1455 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1561 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1562 |
sys.exc_info()[-1].tb_lineno)) |
|
1456 | 1563 |
|
1457 | 1564 |
return ret |
1458 | 1565 |
|
... | ... | |
1460 | 1567 |
@brief get symbol name list |
1461 | 1568 |
@history 18.04.24 Jeongwoo Add isExceptDetect Field |
1462 | 1569 |
''' |
1570 |
|
|
1463 | 1571 |
def getSymbolListByType(self, field_name=None, param=None): |
1464 | 1572 |
ret = [] |
1465 | 1573 |
|
... | ... | |
1469 | 1577 |
if field_name is not None and param is not None: |
1470 | 1578 |
sql = """SELECT a.UID,a.Name,b.Type,a.Threshold,a.MinMatchPoint,a.IsDetectOrigin,a.RotationCount,a.OCROption,a.IsContainChild,a.OriginalPoint,a.ConnectionPoint, |
1471 | 1579 |
a.BaseSymbol,a.AdditionalSymbol,a.IsExceptDetect,a.HasInstrumentLabel,a.flip |
1472 |
FROM Symbol a inner join SymbolType b on a.SymbolType_UID=b.UID WHERE SymbolType_UID = (select UID from SymbolType where {}={})""".format(field_name, self.project.database.place_holder) |
|
1580 |
FROM Symbol a inner join SymbolType b on a.SymbolType_UID=b.UID WHERE SymbolType_UID = (select UID from SymbolType where {}={})""".format( |
|
1581 |
field_name, self.project.database.place_holder) |
|
1473 | 1582 |
else: |
1474 | 1583 |
sql = """SELECT a.UID,a.Name,b.Type,a.Threshold,a.MinMatchPoint,a.IsDetectOrigin,a.RotationCount,a.OCROption,a.IsContainChild,a.OriginalPoint,a.ConnectionPoint, |
1475 | 1584 |
a.BaseSymbol,a.AdditionalSymbol,a.IsExceptDetect,a.HasInstrumentLabel,a.flip FROM Symbol a inner join SymbolType b on a.SymbolType_UID=b.UID""" |
... | ... | |
1479 | 1588 |
if rows is not None and len(rows) > 0: |
1480 | 1589 |
for symbolTuple in rows: |
1481 | 1590 |
sym = symbol.SymbolBase(symbolTuple[1], symbolTuple[2], symbolTuple[3], symbolTuple[4] |
1482 |
, symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], symbolTuple[9] |
|
1483 |
, symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], symbolTuple[14], symbolTuple[0], detectFlip=symbolTuple[15]) ## uid is last item |
|
1591 |
, symbolTuple[5], symbolTuple[6], symbolTuple[7], symbolTuple[8], |
|
1592 |
symbolTuple[9] |
|
1593 |
, symbolTuple[10], symbolTuple[11], symbolTuple[12], symbolTuple[13], |
|
1594 |
symbolTuple[14], symbolTuple[0], |
|
1595 |
detectFlip=symbolTuple[15]) ## uid is last item |
|
1484 | 1596 |
ret.append(sym) |
1485 | 1597 |
except Exception as ex: |
1486 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1598 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1599 |
sys.exc_info()[-1].tb_lineno)) |
|
1487 | 1600 |
|
1488 | 1601 |
return ret |
1489 | 1602 |
|
... | ... | |
1495 | 1608 |
kyouho 2018.07.04 forCheckLineNumber get only inch or metric |
1496 | 1609 |
kyouho 2018.07.16 edit query order by code |
1497 | 1610 |
''' |
1498 |
def getNomialPipeSizeData(self, forCheckLineNumber = False, orderStr = "CODE"): |
|
1611 |
|
|
1612 |
def getNomialPipeSizeData(self, forCheckLineNumber=False, orderStr="CODE"): |
|
1499 | 1613 |
res = [] |
1500 | 1614 |
configs = self.getConfigs('Line No', 'Size Unit') |
1501 | 1615 |
sizeUnit = configs[0].value if 1 == len(configs) else 'Metric' |
... | ... | |
1506 | 1620 |
# Get a cursor object |
1507 | 1621 |
cursor = conn.cursor() |
1508 | 1622 |
|
1509 |
sql = "select UID,Code,Metric,Inch,InchStr,AllowableInchStr,MetricStr,AllowableMetricStr from NominalDiameter ORDER BY {} ASC".format(orderStr) |
|
1623 |
sql = "select UID,Code,Metric,Inch,InchStr,AllowableInchStr,MetricStr,AllowableMetricStr from NominalDiameter ORDER BY {} ASC".format( |
|
1624 |
orderStr) |
|
1510 | 1625 |
cursor.execute(sql) |
1511 | 1626 |
rows = cursor.fetchall() |
1512 | 1627 |
for row in rows: |
1513 |
pipeSize = NominalPipeSize(row[0], row[1], float(row[2]) if row[2] else None, float(row[3]) if row[3] else None, row[4], row[5], row[6], row[7]) |
|
1628 |
pipeSize = NominalPipeSize(row[0], row[1], float(row[2]) if row[2] else None, |
|
1629 |
float(row[3]) if row[3] else None, row[4], row[5], row[6], row[7]) |
|
1514 | 1630 |
pipeSize.sizeUnit = sizeUnit |
1515 | 1631 |
if forCheckLineNumber: |
1516 | 1632 |
if sizeUnit == 'Inch' and pipeSize.inchStr: |
... | ... | |
1521 | 1637 |
res.append(pipeSize) |
1522 | 1638 |
# Catch the exception |
1523 | 1639 |
except Exception as ex: |
1524 |
from App import App |
|
1525 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1640 |
from App import App |
|
1641 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1642 |
sys.exc_info()[-1].tb_lineno) |
|
1526 | 1643 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1527 | 1644 |
|
1528 | 1645 |
return res |
... | ... | |
1532 | 1649 |
@author kyouho |
1533 | 1650 |
@date 2018.07.16 |
1534 | 1651 |
''' |
1652 |
|
|
1535 | 1653 |
def insertNomialPipeSize(self, pipeSizes): |
1536 | 1654 |
conn = self.project.database.connect() |
1537 | 1655 |
with conn: |
... | ... | |
1550 | 1668 |
conn.rollback() |
1551 | 1669 |
|
1552 | 1670 |
from App import App |
1553 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1671 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1672 |
sys.exc_info()[-1].tb_lineno) |
|
1554 | 1673 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1555 | 1674 |
|
1556 | 1675 |
''' |
... | ... | |
1558 | 1677 |
@author kyouho |
1559 | 1678 |
@date 2018.07.16 |
1560 | 1679 |
''' |
1680 |
|
|
1561 | 1681 |
def deleteNomialPipeSize(self): |
1562 | 1682 |
conn = self.project.database.connect() |
1563 | 1683 |
with conn: |
... | ... | |
1568 | 1688 |
conn.commit() |
1569 | 1689 |
except Exception as ex: |
1570 | 1690 |
conn.rollback() |
1571 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1691 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1692 |
sys.exc_info()[-1].tb_lineno)) |
|
1572 | 1693 |
|
1573 | 1694 |
''' |
1574 | 1695 |
@brief convert inch to metric |
1575 | 1696 |
@author kyouho |
1576 | 1697 |
@date 2018.07.09 |
1577 | 1698 |
''' |
1699 |
|
|
1578 | 1700 |
def convertInchToMetric(self, inch): |
1579 | 1701 |
result = '' |
1580 | 1702 |
conn = self.project.database.connect() |
... | ... | |
1582 | 1704 |
try: |
1583 | 1705 |
# Get a cursor object |
1584 | 1706 |
cursor = conn.cursor() |
1585 |
|
|
1707 |
|
|
1586 | 1708 |
sql = "select MetricStr from NominalDiameter WHERE InchStr = ?" |
1587 | 1709 |
param = (inch,) |
1588 | 1710 |
cursor.execute(sql, param) |
... | ... | |
1592 | 1714 |
result = rows[0][0] |
1593 | 1715 |
# Catch the exception |
1594 | 1716 |
except Exception as ex: |
1595 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1717 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1718 |
sys.exc_info()[-1].tb_lineno)) |
|
1596 | 1719 |
|
1597 | 1720 |
return result |
1598 | 1721 |
|
... | ... | |
1601 | 1724 |
@author kyouho |
1602 | 1725 |
@date 2018.07.03 |
1603 | 1726 |
''' |
1727 |
|
|
1604 | 1728 |
def getMaxColorUID(self): |
1605 | 1729 |
result = 0 |
1606 | 1730 |
|
... | ... | |
1617 | 1741 |
result = rows[0][0] |
1618 | 1742 |
# Catch the exception |
1619 | 1743 |
except Exception as ex: |
1620 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1744 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1745 |
sys.exc_info()[-1].tb_lineno)) |
|
1621 | 1746 |
|
1622 | 1747 |
return result |
1623 | 1748 |
|
... | ... | |
1626 | 1751 |
@author kyouho |
1627 | 1752 |
@date 2018.07.09 |
1628 | 1753 |
''' |
1754 |
|
|
1629 | 1755 |
def setPropertyColor(self, _color): |
1630 | 1756 |
conn = self.project.database.connect() |
1631 | 1757 |
with conn: |
... | ... | |
1640 | 1766 |
except Exception as ex: |
1641 | 1767 |
# Roll back any change if something goes wrong |
1642 | 1768 |
conn.rollback() |
1643 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1769 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1770 |
sys.exc_info()[-1].tb_lineno)) |
|
1644 | 1771 |
|
1645 | 1772 |
''' |
1646 | 1773 |
@brief delete Color property |
1647 | 1774 |
@author kyouho |
1648 | 1775 |
@date 2018.07.09 |
1649 | 1776 |
''' |
1777 |
|
|
1650 | 1778 |
def deletePropertyColor(self, property): |
1651 | 1779 |
conn = self.project.database.connect() |
1652 | 1780 |
with conn: |
... | ... | |
1661 | 1789 |
except Exception as ex: |
1662 | 1790 |
# Roll back any change if something goes wrong |
1663 | 1791 |
conn.rollback() |
1664 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1792 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1793 |
sys.exc_info()[-1].tb_lineno)) |
|
1665 | 1794 |
|
1666 | 1795 |
''' |
1667 | 1796 |
@brief get Fluid Code |
... | ... | |
1669 | 1798 |
@date 2018.07.03 |
1670 | 1799 |
@history kyouho 2018.07.04 kyouho 2018.07.04 forCheckLineNumber get only code |
1671 | 1800 |
''' |
1672 |
def getFluidCodeData(self, forCheckLineNumber = False): |
|
1801 |
|
|
1802 |
def getFluidCodeData(self, forCheckLineNumber=False): |
|
1673 | 1803 |
from FluidCodeData import FluidCodeData |
1674 | 1804 |
result = [] |
1675 | 1805 |
|
... | ... | |
1690 | 1820 |
result.append(data) |
1691 | 1821 |
# Catch the exception |
1692 | 1822 |
except Exception as ex: |
1693 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1823 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1824 |
sys.exc_info()[-1].tb_lineno)) |
|
1694 | 1825 |
|
1695 | 1826 |
return result |
1696 | 1827 |
|
... | ... | |
1699 | 1830 |
@author kyouho |
1700 | 1831 |
@date 2018.07.18 |
1701 | 1832 |
''' |
1833 |
|
|
1702 | 1834 |
def checkAttribute(self, attr): |
1703 | 1835 |
conn = self.project.database.connect() |
1704 | 1836 |
with conn: |
... | ... | |
1716 | 1848 |
return False |
1717 | 1849 |
# Catch the exception |
1718 | 1850 |
except Exception as ex: |
1719 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)) |
|
1851 |
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1852 |
sys.exc_info()[-1].tb_lineno)) |
|
1720 | 1853 |
|
1721 | 1854 |
return False |
1722 | 1855 |
|
... | ... | |
1726 | 1859 |
@date 2018.07.18 |
1727 | 1860 |
@history humkyung 2018.10.13 load expression |
1728 | 1861 |
''' |
1862 |
|
|
1729 | 1863 |
def getSymbolAttribute(self, _type): |
1730 | 1864 |
import uuid |
1731 | 1865 |
from SymbolAttr import SymbolAttr |
... | ... | |
1738 | 1872 |
# Get a cursor object |
1739 | 1873 |
cursor = conn.cursor() |
1740 | 1874 |
|
1741 |
sql = self.project.database.to_sql('select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], a.[index], a.[Target], a.[Property] from SymbolAttribute a inner join SymbolType t on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]') |
|
1875 |
sql = self.project.database.to_sql( |
|
1876 |
'select a.UID, a.Attribute, a.DisplayAttribute, a.AttributeType, a.[AttrAt], a.[Expression], a.[index], a.[Target], a.[Property] from SymbolAttribute a inner join SymbolType t on a.SymbolType_UID = t.UID and t.type = ? order by a.[index]') |
|
1742 | 1877 |
param = (_type,) |
1743 | 1878 |
cursor.execute(sql, param) |
1744 | 1879 |
rows = cursor.fetchall() |
... | ... | |
1755 | 1890 |
result.append(attr) |
1756 | 1891 |
# Catch the exception |
1757 | 1892 |
except Exception as ex: |
1758 |
from App import App |
|
1759 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1893 |
from App import App |
|
1894 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1895 |
sys.exc_info()[-1].tb_lineno) |
|
1760 | 1896 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1761 | 1897 |
|
1762 | 1898 |
return result |
... | ... | |
1767 | 1903 |
@date 2018.08.17 |
1768 | 1904 |
@history humkyung 2018.10.13 load expression |
1769 | 1905 |
''' |
1906 |
|
|
1770 | 1907 |
def getSymbolAttributeByUID(self, UID): |
1771 | 1908 |
from SymbolAttr import SymbolAttr |
1772 | 1909 |
|
... | ... | |
1778 | 1915 |
# Get a cursor object |
1779 | 1916 |
cursor = conn.cursor() |
1780 | 1917 |
|
1781 |
sql = 'select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, Property from SymbolAttribute where uid = "{}"'.format(UID) |
|
1918 |
sql = 'select Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, Property from SymbolAttribute where uid = "{}"'.format( |
|
1919 |
UID) |
|
1782 | 1920 |
cursor.execute(sql) |
1783 | 1921 |
rows = cursor.fetchall() |
1784 | 1922 |
if len(rows): |
... | ... | |
1794 | 1932 |
# Catch the exception |
1795 | 1933 |
except Exception as ex: |
1796 | 1934 |
from App import App |
1797 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1935 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1936 |
sys.exc_info()[-1].tb_lineno) |
|
1798 | 1937 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1799 | 1938 |
|
1800 | 1939 |
return res |
... | ... | |
1805 | 1944 |
@date 2018.08.14 |
1806 | 1945 |
@history humkyung 2018.10.13 save expression |
1807 | 1946 |
''' |
1947 |
|
|
1808 | 1948 |
def saveSymbolAttributes(self, type, attrs): |
1809 | 1949 |
conn = self.project.database.connect() |
1810 | 1950 |
with conn: |
... | ... | |
1817 | 1957 |
cursor.execute(sql, param) |
1818 | 1958 |
|
1819 | 1959 |
for attr in attrs: |
1820 |
sql = self.project.database.to_sql('insert into SymbolAttribute(UID, SymbolType_UID, Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, [index]) values(?, ?, ?, ?, ?, ?, ?, ?, ?)') |
|
1960 |
sql = self.project.database.to_sql( |
|
1961 |
'insert into SymbolAttribute(UID, SymbolType_UID, Attribute, DisplayAttribute, AttributeType, AttrAt, Expression, Target, [index]) values(?, ?, ?, ?, ?, ?, ?, ?, ?)') |
|
1821 | 1962 |
attr.insert(1, type) |
1822 | 1963 |
cursor.execute(sql, tuple(attr)) |
1823 | 1964 |
|
... | ... | |
1826 | 1967 |
except Exception as ex: |
1827 | 1968 |
# Roll back any change if something goes wrong |
1828 | 1969 |
conn.rollback() |
1829 |
|
|
1830 |
from App import App |
|
1831 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
1970 |
|
|
1971 |
from App import App |
|
1972 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
1973 |
sys.exc_info()[-1].tb_lineno) |
|
1832 | 1974 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1833 | 1975 |
|
1834 | 1976 |
''' |
... | ... | |
1836 | 1978 |
@author humkyung |
1837 | 1979 |
@date 2018.08.14 |
1838 | 1980 |
''' |
1981 |
|
|
1839 | 1982 |
def saveLineAttributes(self, attrs): |
1840 | 1983 |
conn = self.project.database.connect() |
1841 | 1984 |
with conn: |
... | ... | |
1847 | 1990 |
cursor.execute(sql) |
1848 | 1991 |
|
1849 | 1992 |
for attr in attrs: |
1850 |
sql = self.project.database.to_sql('insert into LineProperties(UID, Name, DisplayName, Type, LimitNumber, [index]) values(?, ?, ?, ?, ?, ?)') |
|
1993 |
sql = self.project.database.to_sql( |
|
1994 |
'insert into LineProperties(UID, Name, DisplayName, Type, LimitNumber, [index]) values(?, ?, ?, ?, ?, ?)') |
|
1851 | 1995 |
cursor.execute(sql, tuple(attr)) |
1852 | 1996 |
|
1853 | 1997 |
conn.commit() |
... | ... | |
1857 | 2001 |
except Exception as ex: |
1858 | 2002 |
# Roll back any change if something goes wrong |
1859 | 2003 |
conn.rollback() |
1860 |
|
|
1861 |
from App import App |
|
1862 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno) |
|
2004 |
|
|
2005 |
from App import App |
|
2006 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
2007 |
sys.exc_info()[-1].tb_lineno) |
|
1863 | 2008 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1864 | 2009 |
|
1865 | 2010 |
''' |
... | ... | |
1867 | 2012 |
@author kyouho |
1868 | 2013 |
@date 2018.08.17 |
1869 | 2014 |
''' |
2015 |
|
|
1870 | 2016 |
def getSymbolTypeId(self, symbolType): |
1871 | 2017 |
result = [] |
1872 | 2018 |
|
... | ... | |
1880 | 2026 |
param = (symbolType,) |
1881 | 2027 |
cursor.execute(sql, param) |
1882 | 2028 |
rows = cursor.fetchall() |
1883 |
|
|
2029 |
|
|
1884 | 2030 |
if len(rows): |
내보내기 Unified diff