개정판 d4f20853
issue #1395: 플러그인 기능 추가
Change-Id: I4abfea2c7e9eef5e825c0dad2ec6f634611fa647
DTI_PID/DTI_PID/App.py | ||
---|---|---|
12 | 12 |
from PyQt5.QtXml import * |
13 | 13 |
from PyQt5.QtSvg import * |
14 | 14 |
from PyQt5 import QtWidgets |
15 |
from PluginScope import PluginScope |
|
15 | 16 |
|
16 | 17 |
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) |
17 | 18 |
from AppDocData import AppDocData |
18 | 19 |
|
19 | 20 |
|
21 |
def plugin(name): |
|
22 |
"""return plugin module""" |
|
23 |
plugin_scope = PluginScope.instance() |
|
24 |
return plugin_scope.get_module(name) |
|
25 |
|
|
26 |
|
|
20 | 27 |
class App(QApplication): |
21 | 28 |
""" This is App class inherits from QApplication """ |
22 | 29 |
|
... | ... | |
122 | 129 |
|
123 | 130 |
if QLicenseDialog.check_license_key(): |
124 | 131 |
dlg = Ui_Dialog() |
132 |
|
|
125 | 133 |
selectedProject = dlg.showDialog() |
126 | 134 |
if selectedProject is not None: |
127 | 135 |
AppDocData.instance().setCurrentProject(selectedProject) |
128 |
#AppDocData.instance().ex = exceptionHandler |
|
136 |
# AppDocData.instance().ex = exceptionHandler
|
|
129 | 137 |
app._mainWnd = MainWindow.instance() |
130 | 138 |
app._mainWnd.show() |
131 |
sys.exit(app.exec_()) |
|
139 |
sys.exit(app.exec_()) |
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
423 | 423 |
|
424 | 424 |
self.tableWidgetInconsistency.clearContents() |
425 | 425 |
self.tableWidgetInconsistency.setRowCount(len(errors)) |
426 |
for index in range(len(errors)):
|
|
427 |
self.makeInconsistencyTableRow(index, errors[index])
|
|
426 |
for index, error in enumerate(errors):
|
|
427 |
self.makeInconsistencyTableRow(index, error) |
|
428 | 428 |
|
429 | 429 |
self.tabWidget_2.setTabText(self.tabWidget_2.indexOf(self.tabInconsistency), |
430 | 430 |
self.tr('Inconsistency') + f"({len(errors)})") |
... | ... | |
1561 | 1561 |
item.setVisible(isChecked) |
1562 | 1562 |
break |
1563 | 1563 |
|
1564 |
''' |
|
1565 |
@brief visible/invisible Text |
|
1566 |
@author humkyung |
|
1567 |
@date 2018.06.28 |
|
1568 |
''' |
|
1569 |
|
|
1570 |
def onViewText(self, isChecked): |
|
1571 |
selected = [item for item in self.graphicsView.scene().items() if issubclass(type(item), QEngineeringTextItem)] |
|
1564 |
def onViewText(self, checked): |
|
1565 |
"""visible/invisible text""" |
|
1566 |
selected = [item for item in self.graphicsView.scene().items() if issubclass(type(item), QEngineeringTextItem) |
|
1567 |
and type(item) is not QEngineeringLineNoTextItem] |
|
1572 | 1568 |
for item in selected: |
1573 |
if type(item) is not QEngineeringLineNoTextItem: |
|
1574 |
item.setVisible(isChecked) |
|
1575 |
|
|
1576 |
''' |
|
1577 |
@brief visible/invisible Symbol |
|
1578 |
@author humkyung |
|
1579 |
@date 2018.06.28 |
|
1580 |
''' |
|
1569 |
item.setVisible(checked) |
|
1581 | 1570 |
|
1582 |
def onViewSymbol(self, isChecked): |
|
1571 |
def onViewSymbol(self, checked): |
|
1572 |
"""visible/invisible symbol""" |
|
1583 | 1573 |
selected = [item for item in self.graphicsView.scene().items() if |
1584 | 1574 |
(issubclass(type(item), SymbolSvgItem) and type(item) is not QEngineeringErrorItem)] |
1585 | 1575 |
for item in selected: |
1586 |
item.setVisible(isChecked)
|
|
1576 |
item.setVisible(checked)
|
|
1587 | 1577 |
|
1588 |
''' |
|
1589 |
@brief visible/invisible Line |
|
1590 |
@author humkyung |
|
1591 |
@date 2018.06.28 |
|
1592 |
''' |
|
1593 |
|
|
1594 |
def onViewLine(self, isChecked): |
|
1578 |
def onViewLine(self, checked): |
|
1579 |
"""visible/invisible line""" |
|
1595 | 1580 |
selected = [item for item in self.graphicsView.scene().items() if type(item) is QEngineeringLineItem] |
1596 | 1581 |
for item in selected: |
1597 |
item.setVisible(isChecked)
|
|
1582 |
item.setVisible(checked)
|
|
1598 | 1583 |
|
1599 | 1584 |
def onViewInconsistency(self, isChecked): |
1600 | 1585 |
''' |
DTI_PID/DTI_PID/PluginScope.py | ||
---|---|---|
1 |
# coding: utf-8 |
|
2 |
""" This is PluginScope class """ |
|
3 |
|
|
4 |
import sys |
|
5 |
import os |
|
6 |
import sqlite3 |
|
7 |
import datetime |
|
8 |
from enum import Enum |
|
9 |
from PIL import PngImagePlugin, JpegImagePlugin |
|
10 |
from PIL import Image |
|
11 |
from PIL.ImageQt import ImageQt |
|
12 |
|
|
13 |
from SingletonInstance import SingletonInstance |
|
14 |
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Plugins')) |
|
15 |
|
|
16 |
|
|
17 |
class PluginScope(SingletonInstance): |
|
18 |
def __init__(self): |
|
19 |
self._classes = {} |
|
20 |
self.load_modules() |
|
21 |
|
|
22 |
def get_module(self, name): |
|
23 |
"""return the class which has given name""" |
|
24 |
return self._classes[name] if name in self._classes else None |
|
25 |
|
|
26 |
def load_modules(self) -> None: |
|
27 |
import os |
|
28 |
import importlib |
|
29 |
from App import App |
|
30 |
|
|
31 |
try: |
|
32 |
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'Plugins') |
|
33 |
plugin_files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and |
|
34 |
(os.path.splitext(f)[1].upper() == '.PY')] |
|
35 |
|
|
36 |
for f in plugin_files: |
|
37 |
module_name = os.path.splitext(os.path.basename(f))[0] |
|
38 |
module = importlib.import_module(module_name) |
|
39 |
_class = getattr(module, module_name) |
|
40 |
self._classes[module_name] = _class(App.instance()) |
|
41 |
except Exception as ex: |
|
42 |
message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename, |
|
43 |
sys.exc_info()[-1].tb_lineno) |
|
44 |
print(message) |
DTI_PID/DTI_PID/Shapes/EngineeringConnectorItem.py | ||
---|---|---|
423 | 423 |
self._underItem = None |
424 | 424 |
# up to here |
425 | 425 |
|
426 |
if items and self.parent not in items and type(items[0]) is QEngineeringLineItem: |
|
426 |
if items and self.parentItem() not in items and \ |
|
427 |
(self.parentItem() is QEngineeringLineItem and type(items[0]) is QEngineeringLineItem): |
|
427 | 428 |
length = items[0].length() * 0.5 |
428 | 429 |
dir = items[0].perpendicular() |
429 |
if self.parent.isHorizontal(): |
|
430 |
if self.parentItem().isHorizontal():
|
|
430 | 431 |
start = [event.scenePos().x() - dir[0] * length, self.parent.start_point()[1] - dir[1] * length] |
431 | 432 |
end = [event.scenePos().x() + dir[0] * length, self.parent.start_point()[1] + dir[1] * length] |
432 | 433 |
else: |
내보내기 Unified diff