프로젝트

일반

사용자정보

개정판 8fb62d43

ID8fb62d438181711007cefc2fc284d107c8706229
상위 d2389ee1
하위 ea6b6336

백흠경이(가) 약 5년 전에 추가함

issue #506: draw white background during mouse is hover

Change-Id: If62c543c0ee6bc693c9e8292f1c25ea73cb9a360

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
23 23
from TextInfo import TextInfo
24 24
from SymbolSvgItem import SymbolSvgItem
25 25

  
26

  
26 27
class QEngineeringTextItem(QGraphicsTextItem, QEngineeringAbstractItem):
27 28
    HIGHLIGHT = '#BC4438'
28 29
    ZVALUE = 210
......
233 234

  
234 235
        painter.setFont(self.font())
235 236
        color = self.defaultTextColor()
236
        # color = QColor('#151485')
237

  
238
        # draw white background during hover
239
        if self.hover:
240
            painter.setPen(Qt.NoPen)
241
            painter.setBrush(Qt.white)
242
            painter.drawRect(self.boundingRect())
243
        # up to here
244

  
237 245
        painter.setPen(QPen(color))
238 246
        painter.drawText(rect, Qt.AlignCenter, self.text())
239 247

  
240 248
        if self.isSelected():
241
            # from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
242 249
            self.drawFocusRect(painter)
243
            # if type(self) is QEngineeringLineNoTextItem:
244
            # for run in self.runs:
245
            # for item in run.items:
246
            # item.setSelected(True)
247 250

  
248 251
    '''
249 252
        @brief      Delete text item
......
309 312
                        return item
310 313
                else:
311 314
                    message = 'error occurred({}) in {}:{}'.format('텍스트 생성에 실패했습니다.',
312
                                                                  sys.exc_info()[-1].tb_frame.f_code.co_filename,
313
                                                                  sys.exc_info()[-1].tb_lineno)
315
                                                                   sys.exc_info()[-1].tb_frame.f_code.co_filename,
316
                                                                   sys.exc_info()[-1].tb_lineno)
314 317
                    self.addMessage.emit(MessageType.Normal, message)
315 318

  
316 319
    '''
......
439 442

  
440 443
                self.setFont(font)
441 444
                rect = self.boundingRect()
445

  
446
                """
447
                doc = self.document()
448
                doc.setDocumentMargin(0)
449
                doc.adjustSize()
450
                doc_size = doc.size()
451

  
452
                sx = rect.width() / doc_size.width()
453
                sy = rect.height() / doc_size.height()
454
                """
455

  
442 456
                sx = width / rect.width()
443 457
                sy = height / rect.height()
444 458

  
445 459
                # if '\n' not in text:
446 460
                transform.translate(x, y)
447
                transform.scale(sx, 1)
461
                # transform.scale(sx, 1)
448 462

  
449 463
            self.setTransform(transform)
450 464

  
......
454 468
            from AppDocData import MessageType
455 469

  
456 470
            message = 'error occurred({}-{}) in {}:{}'.format(ex, self.text(),
457
                                                             sys.exc_info()[-1].tb_frame.f_code.co_filename,
458
                                                             sys.exc_info()[-1].tb_lineno)
471
                                                              sys.exc_info()[-1].tb_frame.f_code.co_filename,
472
                                                              sys.exc_info()[-1].tb_lineno)
459 473
            App.mainWnd().addMessage.emit(MessageType.Error, message)
460 474

  
461 475
    '''
......
482 496
                # up to here
483 497
        except Exception as ex:
484 498
            print('error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
485
                                                      sys.exc_info()[-1].tb_lineno))
499
                                                       sys.exc_info()[-1].tb_lineno))
486 500

  
487 501
        return visited
488 502

  
......
539 553
            from AppDocData import MessageType
540 554

  
541 555
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
542
                                                          sys.exc_info()[-1].tb_lineno)
556
                                                           sys.exc_info()[-1].tb_lineno)
543 557
            App.mainWnd().addMessage.emit(MessageType.Error, message)
544 558
            return None
545 559

  
......
606 620
            from AppDocData import MessageType
607 621

  
608 622
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
609
                                                          sys.exc_info()[-1].tb_lineno)
623
                                                           sys.exc_info()[-1].tb_lineno)
610 624
            App.mainWnd().addMessage.emit(MessageType.Error, message)
611 625

  
612 626
        return item
......
682 696
            from AppDocData import MessageType
683 697

  
684 698
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
685
                                                          sys.exc_info()[-1].tb_lineno)
699
                                                           sys.exc_info()[-1].tb_lineno)
686 700
            App.mainWnd().addMessage.emit(MessageType.Error, message)
687 701

  
688 702
            return None
......
721 735
            for symbol in target_symbols:
722 736
                if issubclass(type(symbol), SymbolSvgItem):
723 737
                    dx = symbol.center().x() - center.x()
724
                    dy = symbol.center().y() - center.y()            
738
                    dy = symbol.center().y() - center.y()
725 739

  
726 740
                    offset = (symbol.sceneBoundingRect().width() + symbol.sceneBoundingRect().height()) / 4
727
                    length = math.sqrt(dx*dx + dy*dy) - offset
728
                    
741
                    length = math.sqrt(dx * dx + dy * dy) - offset
742

  
729 743
                    if (length < dist) and (minDist is None or length < minDist):
730 744
                        minDist = length
731 745
                        selected = symbol
......
745 759
                else:
746 760
                    return False
747 761
        except Exception as ex:
748
            from App import App 
749
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
762
            from App import App
763
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
764
                                                           sys.exc_info()[-1].tb_lineno)
750 765
            App.mainWnd().addMessage.emit(MessageType.Error, message)
751 766

  
752 767
    '''
......
755 770
        @date       2018.05.11
756 771
        @history    humkyung 2018.05.13 update after change color
757 772
    '''
773

  
758 774
    def setColor(self, color):
759 775
        if QColor.isValidColor(color):
760 776
            c = QColor()
......
774 790
        values = ['?', '?', "(select UID from Symbol where Name='Text' and SymbolType_UID=-1)", '?', '?', '?', '?', '?',
775 791
                  '?', '?', '?', '?', '?']
776 792

  
777
        param = [(str(self.uid), str(appDocData.activeDrawing.UID), self.loc[0], self.loc[1], self.size[0], self.size[1],
778
                  str(self.angle),
779
                  self.area, self.text(), \
780
                  str(self.owner) if self.owner else None, \
781
                  str(self.conns[0]) if self.conns else None, \
782
                  str(self.special_item_type) if self.special_item_type else None)]
793
        param = [
794
            (str(self.uid), str(appDocData.activeDrawing.UID), self.loc[0], self.loc[1], self.size[0], self.size[1],
795
             str(self.angle),
796
             self.area, self.text(), \
797
             str(self.owner) if self.owner else None, \
798
             str(self.conns[0]) if self.conns else None, \
799
             str(self.special_item_type) if self.special_item_type else None)]
783 800
        sql = 'insert into Components({}) values({})'.format(','.join(cols), ','.join(values))
784 801
        res.append((sql, tuple(param)))
785 802

  

내보내기 Unified diff

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