프로젝트

일반

사용자정보

개정판 64869dd3

ID64869dd38c39976e3037ab0218cee6f21cc4cc8f
상위 f118995a
하위 fbe7952a

백흠경이(가) 4년 이상 전에 추가함

issue #366: QEngineeringLineItem 표시 기능 개선(#2)

Change-Id: I0992e96ee5640b23867dfd5d611b530077e21c1f

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
27 27
    ARROW_SIZE = 30
28 28
    ZVALUE = 100
29 29
    HIGHLIGHT = '#BC4438'
30
    HIGHLIGHT_BRUSH = QBrush(QColor(QEngineeringAbstractItem.SELECTED_COLOR))
30 31
    LINE_TYPE_COLORS = {}
31 32

  
32 33
    '''
......
49 50
            self.thickness = thickness
50 51

  
51 52
            self.setPen(QPen(Qt.blue, 4, Qt.SolidLine))  # set default pen
53
            self._minimum_bounding_box = None
52 54
            self.isCreated = True
53 55

  
54 56
            self._owner = None
......
57 59
            self._lineType = None
58 60
            self.lineType = configs[0].value if 1 == len(configs) else 'Secondary'  # default line type is 'Secondary'
59 61

  
60
            #self._properties = {SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'): None}
61 62
            self._properties = {}
62 63

  
63 64
            self.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsFocusable)
......
248 249
        self.connectors[1].setPos(line[1])
249 250
        self.update_arrow()
250 251

  
252
        self._minimum_bounding_box = None
253

  
254
    @property
255
    def minimum_bounding_box(self):
256
        """calculate minimum bounding box of line"""
257
        import math
258

  
259
        if not self._minimum_bounding_box:
260
            offset = 10
261

  
262
            angle = self.line().angle() * math.pi / 180
263
            dx = offset * math.sin(angle)
264
            dy = offset * math.cos(angle)
265
            offset1 = QPointF(dx, dy)
266
            offset2 = QPointF(-dx, -dy)
267

  
268
            polygon = QPolygonF()
269
            polygon << self.line().p1() + offset1 << self.line().p1() + offset2 << \
270
            self.line().p2() + offset2 << self.line().p2() + offset1
271

  
272
            self._minimum_bounding_box = polygon
273

  
274
        return self._minimum_bounding_box
275

  
251 276
    '''
252 277
        @brief  return start point
253 278
        @author humkyung
......
1425 1450
        path.lineTo(x2, y2)
1426 1451

  
1427 1452
        stroke = QPainterPathStroker()
1428
        stroke.setWidth(10)
1453
        stroke.setWidth(15)
1429 1454
        return stroke.createStroke(path)
1430 1455

  
1431 1456
    def paint(self, painter, option, widget):
......
1436 1461
        painter.setPen(self.pen())
1437 1462
        painter.drawLine(self.line())
1438 1463

  
1464
        if self.isSelected():
1465
            painter.setOpacity(0.7)
1466
            painter.setPen(QPen(Qt.black, 1.5, Qt.DashLine))
1467
            painter.setBrush(QEngineeringLineItem.HIGHLIGHT_BRUSH)
1468
            painter.drawPolygon(self.minimum_bounding_box)
1469

  
1439 1470
    def drawToImage(self, img, color, thickness):
1440 1471
        """write recognized lines to image"""
1441 1472
        try:
......
1919 1950

  
1920 1951
        start = self.connectors[0].center()
1921 1952
        end = self.connectors[1].center()
1922
        self.setLine(start[0], start[1], end[0], end[1])
1923
        self.update()
1924

  
1925
        self.setToolTip(self.tooltip)
1926
        self.update_arrow()
1953
        self.set_line([[start[0], start[1]], [end[0], end[1]]])
1927 1954

  
1928 1955
        if hasattr(self.scene(), 'contents_changed'):
1929 1956
            self.scene().contents_changed.emit()

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)