프로젝트

일반

사용자정보

개정판 bf6e8026

IDbf6e80263c764f26d2548958f2016f230fc1f8f1
상위 0cf9f45b
하위 22f192d5, 239fd8c5

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

issue #366: EngineeringLine 표시 기능 개선

Change-Id: I95277c2312727236e0b75865a615cf67e3dfe3fa

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringAbstractItem.py
12 12
    '''
13 13
    DEFAULT_COLOR = '#0000FF'
14 14
    HOVER_COLOR = '#BC4438'
15
    SELECTED_COLOR = '#FF00BF'
15 16

  
16 17
    CONNECTED_AT_PT = 0
17 18
    CONNECTED_AT_BODY = 1
......
127 128
            if DisplayOptions.DisplayByLineType == DisplayColors.instance().option:
128 129
                if self.hover:
129 130
                    return QEngineeringAbstractItem.HOVER_COLOR
131
                elif self.isSelected():
132
                    return QEngineeringAbstractItem.SELECTED_COLOR
130 133
                else:
131 134
                    if self.lineType in QEngineeringLineItem.LINE_TYPE_COLORS:
132 135
                        return QEngineeringLineItem.LINE_TYPE_COLORS[self.lineType]
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
1445 1445
            self.flowMark = int(configs[0].value) if 1 == len(configs) else 100
1446 1446
        self.update_arrow()
1447 1447

  
1448
    '''
1449
        @brief  draw rect when item is selected
1450
        @author humkyung
1451
        @date   2018.07.07
1452
    '''
1453

  
1454
    def drawFocusRect(self, painter):
1455
        self.focuspen = QPen(Qt.DotLine)
1456
        self.focuspen.setColor(Qt.black)
1457
        self.focuspen.setWidthF(1.5)
1458
        hilightColor = QColor(255, 0, 0, 127)
1459
        painter.setBrush(QBrush(hilightColor))
1460
        painter.setPen(self.focuspen)
1461
        painter.drawRect(self.boundingRect())
1448
    def shape(self):
1449
        """return shape for non-rectangle shape"""
1450
        x1, y1, x2, y2 = self.line().x1(), self.line().y1(), self.line().x2(), self.line().y2()
1451
        path = QPainterPath()
1452
        path.moveTo(x1, y1)
1453
        path.lineTo(x2, y2)
1462 1454

  
1463
    '''
1464
        @brief      override paint method
1465
        @history    humkyung 2018.08.30 draw flowmark only for Primary or Secondary
1466
    '''
1455
        stroke = QPainterPathStroker()
1456
        stroke.setWidth(10)
1457
        return stroke.createStroke(path)
1467 1458

  
1468 1459
    def paint(self, painter, option, widget):
1460
        """override paint method"""
1469 1461
        color = self.getColor()
1470 1462
        self.setColor(color)
1471 1463

  
1472
        QGraphicsLineItem.paint(self, painter, option, widget)
1473

  
1474
        if self.isSelected():
1475
            self.drawFocusRect(painter)
1464
        painter.setPen(self.pen())
1465
        painter.drawLine(self.line())
1476 1466

  
1477 1467
    def drawToImage(self, img, color, thickness):
1478 1468
        """write recognized lines to image"""
......
1482 1472
            cv2.line(img, (round(ptStart[0]), round(ptStart[1])), (round(ptEnd[0]), round(ptEnd[1])), color, thickness)
1483 1473
            # up to here
1484 1474
        except Exception as ex:
1485
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
1486
                                                       sys.exc_info()[-1].tb_lineno))
1475
            message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \
1476
                      f"{sys.exc_info()[-1].tb_lineno}"
1487 1477

  
1488 1478
    @staticmethod
1489 1479
    def from_database(component):
......
1867 1857
    def deleteLineItemFromScene(self):
1868 1858
        self.scene().removeItem(self)
1869 1859

  
1870
    '''
1871
        @brief      Set Color. Override QEngineeringAbstractItem's
1872
        @author     Jeongwoo
1873
        @date       2018.05.11
1874
        @history    2018.05.11  Jeongwoo    Add self.setPen() Method
1875
        @history    humkyung 2018.05.13 call setPen method to apply changed color
1876
    '''
1877 1860
    def setColor(self, color):
1878
        c = QColor()
1879
        c.setNamedColor(color)
1880
        _pen = self.pen()
1881
        _pen.setColor(c)
1882
        self.setPen(_pen)
1883
        self.update()
1861
        """Set Color. Override QEngineeringAbstractItem's"""
1862
        if color != self.pen().color().name():
1863
            c = QColor()
1864
            c.setNamedColor(color)
1865
            _pen = self.pen()
1866
            _pen.setColor(c)
1867
            self.setPen(_pen)
1868
            self.update()
1884 1869

  
1885 1870
    def clear_labels(self):
1886 1871
        """ clear spec labels """

내보내기 Unified diff