개정판 db1fa308
issue #538: revised 키 입력으로 심볼 이동, 마우스 이동으로 심볼 회전
Change-Id: I51cb16bb3b7ff61bd511df09ea937fc50c403119
DTI_PID/DTI_PID/QtImageViewer.py | ||
---|---|---|
672 | 672 |
svg.connectors[0].connectedItem = items[0].parentItem() |
673 | 673 |
items[0].connectedItem = svg |
674 | 674 |
|
675 |
svg.reSettingConnetors() |
|
675 |
#svg.reSettingConnetors()
|
|
676 | 676 |
|
677 | 677 |
self.scene.clearFocus() |
678 | 678 |
for item in self.scene.selectedItems(): |
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py | ||
---|---|---|
1112 | 1112 |
self.setColor(color) |
1113 | 1113 |
|
1114 | 1114 |
QGraphicsLineItem.paint(self, painter, option, widget) |
1115 |
""" |
|
1116 |
for child in self.childItems(): |
|
1117 |
child.setBrush(self.pen().color()) |
|
1118 |
""" |
|
1119 |
|
|
1120 |
""" |
|
1121 |
if self.lineType == 'Primary' or self.lineType == 'Secondary': |
|
1122 |
## draw direction mark |
|
1123 |
length = self.length() |
|
1124 |
if length > 0: |
|
1125 |
ptStart = self.startPoint() |
|
1126 |
ptEnd = self.endPoint() |
|
1127 |
|
|
1128 |
_dir = [(ptEnd[0] - ptStart[0])/self.length(), (ptEnd[1] - ptStart[1])/self.length()] |
|
1129 |
perpendicular = (-_dir[1], _dir[0]) |
|
1130 |
## up to here |
|
1131 |
""" |
|
1132 | 1115 |
|
1133 | 1116 |
if self.isSelected(): |
1134 | 1117 |
self.drawFocusRect(painter) |
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py | ||
---|---|---|
371 | 371 |
''' |
372 | 372 |
|
373 | 373 |
def itemChange(self, change, value): |
374 |
""" call signals when item's position is changed """ |
|
375 |
if change == QGraphicsItem.ItemPositionChange: |
|
374 |
""" call signals when item's position or rotation is changed """ |
|
375 |
if change == QGraphicsItem.ItemPositionChange or change == QGraphicsItem.ItemRotationChange: |
|
376 |
for conn in self.connectors: |
|
377 |
conn.sceneConnectPoint = (conn.sceneBoundingRect().center().x(), conn.sceneBoundingRect().center().y()) |
|
378 |
|
|
379 |
from EngineeringLineItem import QEngineeringLineItem |
|
380 |
for connector in self.connectors: |
|
381 |
if connector.connectedItem is not None and type(connector.connectedItem) == QEngineeringLineItem: |
|
382 |
line = connector.connectedItem |
|
383 |
line.reDrawLine(self, connector.center()) |
|
384 |
line.update_arrow() |
|
385 |
|
|
386 |
self.size[0], self.size[1] = round(self.sceneBoundingRect().width()), round(self.sceneBoundingRect().height()) |
|
387 |
|
|
376 | 388 |
return value |
377 | 389 |
|
378 | 390 |
return super().itemChange(change, value) |
... | ... | |
741 | 753 |
self.__angle = -self.__angle if cross < 0 else self.__angle |
742 | 754 |
|
743 | 755 |
self.rotate(self.symbolOrigin, -self.__angle) |
744 |
self.reSettingConnetors() |
|
745 | 756 |
|
746 | 757 |
def removeSelfAttr(self, attributeName): |
747 | 758 |
target = None |
... | ... | |
821 | 832 |
scene.removeItem(self) |
822 | 833 |
self.addSvgItemToScene(scene) |
823 | 834 |
self.setZValue(z) |
824 |
|
|
825 |
self.reSettingConnetors() |
|
826 | 835 |
elif event.key() == Qt.Key_Escape: |
827 | 836 |
if hasattr(self, '_rotating'): |
828 | 837 |
self.ungrabMouse() |
... | ... | |
832 | 841 |
transform.rotateRadians(self.angle) |
833 | 842 |
transform.translate(-self.symbolOrigin[0], -self.symbolOrigin[1]) |
834 | 843 |
self.setTransform(transform) |
835 |
self.reSettingConnetors() |
|
836 | 844 |
|
837 | 845 |
del self._rotating |
838 | 846 |
elif event.key() == Qt.Key_Up: ### translate up/down/left/right symbol |
839 | 847 |
self.moveBy(0, -1) |
840 |
#self.loc[1] = self.loc[1] - 1 |
|
841 |
self.reSettingConnetors() |
|
842 | 848 |
elif event.key() == Qt.Key_Down: |
843 | 849 |
self.moveBy(0, 1) |
844 |
#self.loc[1] = self.loc[1] + 1 |
|
845 |
self.reSettingConnetors() |
|
846 | 850 |
elif event.key() == Qt.Key_Left: |
847 | 851 |
self.moveBy(-1, 0) |
848 |
#self.loc[0] = self.loc[0] - 1 |
|
849 |
self.reSettingConnetors() |
|
850 | 852 |
elif event.key() == Qt.Key_Right: |
851 | 853 |
self.moveBy(1, 0) |
852 |
#self.loc[0] = self.loc[0] + 1 |
|
853 |
self.reSettingConnetors() |
|
854 | 854 |
|
855 | 855 |
''' |
856 | 856 |
@brief connect attribute |
... | ... | |
1414 | 1414 |
painter.setPen(self.focuspen) |
1415 | 1415 |
painter.drawRect(self.boundingRect()) |
1416 | 1416 |
|
1417 |
#painter.drawEllipse(QPointF(0, 0), 10, 10) |
|
1418 |
|
|
1419 | 1417 |
''' |
1420 | 1418 |
@brief override paint(draw connection points) |
1421 | 1419 |
@author humkyung |
... | ... | |
1518 | 1516 |
|
1519 | 1517 |
currentPoint = self.getCurrentPoint() |
1520 | 1518 |
self.rotate(currentPoint, self.angle) |
1521 |
self.reSettingConnetors() |
|
1522 | 1519 |
|
1523 | 1520 |
''' |
1524 | 1521 |
@brief rotate Symbol |
... | ... | |
1546 | 1543 |
|
1547 | 1544 |
currentPoint = self.getCurrentPoint() |
1548 | 1545 |
self.rotate(currentPoint, self.angle) |
1549 |
self.reSettingConnetors() |
|
1550 | 1546 |
|
1551 |
''' |
|
1552 |
@brief resetting rotate Symbol |
|
1553 |
@author kyouho |
|
1554 |
@date 2018.07.24 |
|
1555 |
''' |
|
1556 |
def rotate(self, standardPoint, angle): |
|
1547 |
def get_transform(self, pt, angle): |
|
1548 |
""" return a transform """ |
|
1557 | 1549 |
transform = QTransform() |
1558 | 1550 |
transform.translate(self.loc[0] + self.symbolOrigin[0], self.loc[1] + self.symbolOrigin[1]) |
1559 | 1551 |
transform.rotateRadians(-angle) |
1560 |
transform.translate(-standardPoint[0], -standardPoint[1])
|
|
1552 |
transform.translate(-pt[0], -pt[1])
|
|
1561 | 1553 |
|
1562 | 1554 |
if self.flip is 1: |
1563 | 1555 |
transform.scale(-1.0, 1.0) |
1564 | 1556 |
transform.translate(-2 * self.symbolOrigin[0], 0) |
1565 | 1557 |
|
1566 |
self.setTransform(transform) |
|
1567 |
|
|
1568 |
def reSettingConnetors(self): |
|
1569 |
for conn in self.connectors: |
|
1570 |
conn.sceneConnectPoint = (conn.sceneBoundingRect().center().x(), conn.sceneBoundingRect().center().y()) |
|
1571 |
|
|
1572 |
from EngineeringLineItem import QEngineeringLineItem |
|
1573 |
for connector in self.connectors: |
|
1574 |
if connector.connectedItem is not None and type(connector.connectedItem) == QEngineeringLineItem: |
|
1575 |
line = connector.connectedItem |
|
1576 |
line.reDrawLine(self, connector.center()) |
|
1577 |
line.update_arrow() |
|
1558 |
return transform |
|
1578 | 1559 |
|
1579 |
self.size[0], self.size[1] = round(self.sceneBoundingRect().width()), round(self.sceneBoundingRect().height()) |
|
1560 |
''' |
|
1561 |
@brief resetting rotate Symbol |
|
1562 |
@author kyouho |
|
1563 |
@date 2018.07.24 |
|
1564 |
''' |
|
1565 |
def rotate(self, standardPoint, angle): |
|
1566 |
self.setRotation(0) # force to emit itemChange signal |
|
1567 |
self.setTransform(self.get_transform(standardPoint, angle)) |
|
1580 | 1568 |
|
1581 | 1569 |
''' |
1582 | 1570 |
@brief change Conn point |
... | ... | |
1616 | 1604 |
@date 2018.07.25 |
1617 | 1605 |
''' |
1618 | 1606 |
def getCurrentPoint(self): |
1619 |
#from EngineeringSpecBreakItem import QEngineeringSpecBreakItem |
|
1620 |
|
|
1621 | 1607 |
pointList = [] |
1622 | 1608 |
pointList.append(self.symbolOrigin) |
1623 | 1609 |
for connector in self.connectors: |
1624 | 1610 |
pointList.append(connector.connectPoint) |
1625 | 1611 |
|
1626 |
#if type(self) is QEngineeringSpecBreakItem: |
|
1627 |
# self.currentPointModeIndex = 1 |
|
1628 |
|
|
1629 | 1612 |
return pointList[self.currentPointModeIndex] |
1630 | 1613 |
|
1631 | 1614 |
''' |
... | ... | |
1634 | 1617 |
@date 18.08.06 |
1635 | 1618 |
''' |
1636 | 1619 |
def reCalculationRotatedItem(self): |
1637 |
transform = QTransform() |
|
1638 |
transform.translate(self.loc[0] + self.symbolOrigin[0], self.loc[1] + self.symbolOrigin[1]) |
|
1639 |
transform.rotateRadians(-self.angle) |
|
1640 |
currentPoint = self.getCurrentPoint() |
|
1641 |
transform.translate(-currentPoint[0], -currentPoint[1]) |
|
1642 |
# 시작점을 구하기 위해서 |
|
1643 |
goPoint = transform.map(QPoint(self.symbolOrigin[0], self.symbolOrigin[1])) |
|
1644 |
|
|
1620 |
goPoint = self.get_transform(self.getCurrentPoint(), self.angle).map(QPoint(self.symbolOrigin[0], self.symbolOrigin[1])) |
|
1645 | 1621 |
self.loc = [self.loc[0] + self.origin[0] - goPoint.x(), self.loc[1] + self.origin[1] - goPoint.y()] |
1646 | 1622 |
|
1647 |
|
|
1648 | 1623 |
def recursiveChangeAttributes(node, attName, attValue): |
1649 | 1624 |
while not node.isNull(): |
1650 | 1625 |
if node.isElement(): |
... | ... | |
1663 | 1638 |
@date 2018.06.18 |
1664 | 1639 |
''' |
1665 | 1640 |
class Transfer(QObject): |
1641 |
on_pos_changed = pyqtSignal(QGraphicsItem) |
|
1666 | 1642 |
onRemoved = pyqtSignal(QGraphicsItem) |
1667 | 1643 |
|
1668 | 1644 |
def __init__(self, parent = None): |
내보내기 Unified diff