개정판 31e27f1c
issue #538: eq package -> eq symbol test
Change-Id: I59fac13fc392d4f23f15ced6f3cc5c54fa5afc0f
DTI_PID/DTI_PID/MainWindow.py | ||
---|---|---|
1797 | 1797 |
points.append([round(conn.center()[0] - rect.x()), round(conn.center()[1] - rect.y())]) |
1798 | 1798 |
poly = np.array(points, np.int32) |
1799 | 1799 |
|
1800 |
mask = np.zeros((int(rect.height()), int(rect.width()))) |
|
1801 |
cv2.fillPoly(mask, [poly], (255)) |
|
1802 |
poly_copied = np.multiply(mask, symbol_image[round(rect.y()):round(rect.y() + rect.height()), |
|
1803 |
round(rect.x()):round(rect.x() + rect.width())]) |
|
1804 |
|
|
1805 |
#mask = np.ones(src2) |
|
1800 |
#mask = np.zeros((int(rect.height()), int(rect.width()))) |
|
1801 |
#cv2.fillPoly(mask, [poly], (255)) |
|
1802 |
#poly_copied = np.multiply(mask, symbol_image[round(rect.y()):round(rect.y() + rect.height()), |
|
1803 |
# round(rect.x()):round(rect.x() + rect.width())]) |
|
1806 | 1804 |
#cv2.fillPoly(mask,[poly],0) |
1807 | 1805 |
#src2 = np.multiply(mask,src2) |
1808 | 1806 |
|
1809 |
#src2 = np.add(poly_copied,src2) |
|
1810 |
print('a') |
|
1807 |
mask = np.ones((int(rect.height()), int(rect.width())), dtype=np.uint8) * 255 |
|
1808 |
cv2.fillConvexPoly(mask, poly, (0)) |
|
1809 |
sym_img = cv2.bitwise_or(mask, symbol_image[round(rect.y()):round(rect.y() + rect.height()), round(rect.x()):round(rect.x() + rect.width())]) |
|
1810 |
sym_img = cv2.merge((sym_img, sym_img, sym_img)) |
|
1811 |
|
|
1812 |
h, w, c = sym_img.shape |
|
1813 |
qImg = QImage(sym_img.data, w, h, w * c, QImage.Format_RGB888) |
|
1814 |
#pixmap = QPixmap.fromImage(qImg) |
|
1815 |
|
|
1816 |
self.onAreaSelected(None, None, None, None, package=qImg, position=rect.topLeft()) |
|
1817 |
|
|
1818 |
selected[0].transfer.onRemoved.emit(selected[0]) |
|
1811 | 1819 |
else: |
1812 | 1820 |
cmd = FenceCommand.FenceCommand(self.graphicsView) |
1813 | 1821 |
cmd.onSuccess.connect(self.onAreaSelected) |
... | ... | |
1820 | 1828 |
@date 2018.07.20 |
1821 | 1829 |
''' |
1822 | 1830 |
|
1823 |
def onAreaSelected(self, x, y, width, height): |
|
1831 |
def onAreaSelected(self, x, y, width, height, package=False, position=None):
|
|
1824 | 1832 |
try: |
1825 | 1833 |
image = self.graphicsView.image() |
1826 | 1834 |
if image is not None: |
1827 |
symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, image.copy(x, y, width, height), |
|
1828 |
AppDocData.instance().getCurrentProject()) |
|
1835 |
if not package: |
|
1836 |
symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, image.copy(x, y, width, height), |
|
1837 |
AppDocData.instance().getCurrentProject()) |
|
1838 |
else: |
|
1839 |
symbolEditorDialog = SymbolEditorDialog.QSymbolEditorDialog(self, package, |
|
1840 |
AppDocData.instance().getCurrentProject(), package=True) |
|
1829 | 1841 |
(isAccepted, isImmediateInsert, offsetX, offsetY, newSym) = symbolEditorDialog.showDialog() |
1830 | 1842 |
# TODO: not initialize symbol tree view when user reject to create a new symbol |
1831 | 1843 |
self.symbolTreeWidget.initSymbolTreeView() |
1832 | 1844 |
if isAccepted: |
1833 | 1845 |
if isImmediateInsert: |
1834 |
svgPath = newSym.getSvgFileFullPath() |
|
1835 |
img = cv2.imread(newSym.getImageFileFullPath(), 1) |
|
1836 |
w, h = (0, 0) |
|
1837 |
if len(img.shape[::-1]) == 2: |
|
1838 |
w, h = img.shape[::-1] |
|
1839 |
else: |
|
1840 |
_chan, w, h = img.shape[::-1] |
|
1841 |
svg = SymbolSvgItem(svgPath) |
|
1842 |
svg.buildItem(newSym.getName(), newSym.getType(), 0, [offsetX, offsetY], [w, h], |
|
1843 |
[float(x) for x in newSym.getOriginalPoint().split(',')], |
|
1844 |
[(float(x.split(',')[0]), float(x.split(',')[1])) for x in |
|
1845 |
newSym.getConnectionPoint().split('/')], newSym.getBaseSymbol(), |
|
1846 |
newSym.getAdditionalSymbol(), newSym.getHasInstrumentLabel) |
|
1847 |
|
|
1848 |
svg.transfer.onRemoved.connect(self.itemTreeWidget.itemRemoved) |
|
1849 |
svg.addSvgItemToScene(self.graphicsView.scene()) |
|
1850 |
for connector in svg.connectors: |
|
1851 |
self.graphicsView.scene().addItem(connector) |
|
1846 |
svg = QtImageViewer.createSymbolObject(newSym.getName()) |
|
1847 |
offsetX, offsetY = [int(point) for point in newSym.getOriginalPoint().split(',')] |
|
1848 |
QtImageViewer.matchSymbolToLine(self.graphicsView.scene(), svg, QPoint(position.x() + offsetX, position.y() + offsetY)) |
|
1852 | 1849 |
finally: |
1853 | 1850 |
self.onCommandRejected() |
1854 | 1851 |
QApplication.restoreOverrideCursor() |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
1742 | 1742 |
item = QEngineeringOPCItem(path, uid, flip=flip) |
1743 | 1743 |
elif type == 'Nozzles': |
1744 | 1744 |
item = QEngineeringNozzleItem(path, uid, flip=flip) |
1745 |
elif cateogry == 'Equipment' or cateogry == 'Equipment Components': |
|
1745 |
elif cateogry == 'Equipment' or cateogry == 'Equipment Components' or cateogry == 'Package':
|
|
1746 | 1746 |
item = QEngineeringEquipmentItem(path, uid, flip=flip) |
1747 | 1747 |
elif cateogry == 'Instrumentation': |
1748 | 1748 |
item = QEngineeringInstrumentItem(path, uid, flip=flip) |
DTI_PID/DTI_PID/SymbolEditorDialog.py | ||
---|---|---|
58 | 58 |
2018.07.03 Yecheol Rename File, Is Instrument Label added |
59 | 59 |
''' |
60 | 60 |
|
61 |
def __init__(self, parent, image, project, selectedSymbol=None, display=False): |
|
61 |
def __init__(self, parent, image, project, selectedSymbol=None, display=False, package=False):
|
|
62 | 62 |
QDialog.__init__(self, parent) |
63 | 63 |
|
64 | 64 |
try: |
65 | 65 |
self.setWindowFlag(Qt.WindowMinMaxButtonsHint) |
66 | 66 |
self.image = image |
67 | 67 |
self.display = display |
68 |
self.package = package |
|
68 | 69 |
|
69 | 70 |
self.selectedSymbol = selectedSymbol |
70 | 71 |
self.project = project |
... | ... | |
84 | 85 |
|
85 | 86 |
self.conn_index = 1 |
86 | 87 |
|
88 |
self.offsetX = 0 |
|
89 |
self.offsetY = 0 |
|
87 | 90 |
self.setupImageViewer() |
88 | 91 |
self.setupTools() |
89 | 92 |
self.initForms() |
90 | 93 |
self.initContents() |
91 | 94 |
self.isAccepted = False |
92 |
self.offsetX = 0 |
|
93 |
self.offsetY = 0 |
|
94 | 95 |
self.newSym = None |
95 | 96 |
|
96 | 97 |
self.ui.addTextAreaButton.clicked.connect(self.onSelectTextArea) |
... | ... | |
537 | 538 |
row = row + 1 |
538 | 539 |
|
539 | 540 |
self.ui.tableWidgetConnList.resizeColumnsToContents() |
541 |
elif self.package: |
|
542 |
self.fitImageToolClickEvent(None) |
|
543 |
|
|
544 |
category = self.ui.treeViewSymbolCategory.model().sourceModel().findItems('Package', Qt.MatchExactly) |
|
545 |
if category: |
|
546 |
proxy_model = self.ui.treeViewSymbolCategory.model() |
|
547 |
index = proxy_model.sourceModel().indexFromItem(category[0]) |
|
548 |
self.ui.treeViewSymbolCategory.expand(proxy_model.mapFromSource(index)) |
|
549 |
for row in range(category[0].rowCount()): |
|
550 |
child = category[0].child(row) |
|
551 |
if child.text() == 'None': |
|
552 |
index = self.ui.treeViewSymbolCategory.model().sourceModel().indexFromItem(child) |
|
553 |
self.ui.treeViewSymbolCategory.setCurrentIndex(proxy_model.mapFromSource(index)) |
|
554 |
|
|
555 |
originalPoint = str(round(self.ui.imageView.image().width() / 2)) + ',' + str(round(self.ui.imageView.image().height() / 2)) |
|
556 |
self.ui.originalPointLineEdit.setText(originalPoint) |
|
557 |
OriginalPointCommand.OriginalPointCommand.drawCircle(self.ui.imageView, originalPoint.split(",")[0], |
|
558 |
originalPoint.split(",")[1]) |
|
559 |
self.ui.imageView.isOriginalPointSelected = True |
|
560 |
|
|
561 |
self.ui.isExceptDetectCheckBox.setChecked(True) |
|
562 |
self.ui.immediateInsertCheckBox.setChecked(True) |
|
563 |
|
|
564 |
# no used |
|
565 |
self.ui.minMatchPointLineEdit.setText('0') |
|
540 | 566 |
else: |
567 |
# no used |
|
541 | 568 |
self.ui.minMatchPointLineEdit.setText('0') |
542 | 569 |
except Exception as ex: |
543 | 570 |
from App import App |
minorTools/xmlTextSearcher.py | ||
---|---|---|
3 | 3 |
def finder(): |
4 | 4 |
print("finder start") |
5 | 5 |
|
6 |
targetText = ['3-WAY VALVE<']
|
|
6 |
targetText = ['Instrumen Box<']
|
|
7 | 7 |
path = 'W:\ID2_Project\ISU\Temp' |
8 | 8 |
|
9 | 9 |
print("target : " + str(len(targetText))) |
내보내기 Unified diff