프로젝트

일반

사용자정보

개정판 ff64de8e

IDff64de8e39d00559ecdbd7d4e7d362b7135529d9
상위 2c7b34fc
하위 a63b9702, 199a40bd

함의성이(가) 10달 전에 추가함

add multi line size, line no text test

Change-Id: I33d8eb1310228f5e0be01375f632893c5179b9d4

차이점 보기:

DTI_PID/DTI_PID/Shapes/EngineeringTextItem.py
742 742
        width = self.size[0]
743 743
        height = self.size[1]
744 744

  
745
        line_count = self.text().count('\n') + 1
746

  
745 747
        allowed_error = 0.01
746 748
        if abs(self.angle - 1.57) < allowed_error or abs(self.angle - 4.71) < allowed_error:
747 749
            font = QFont(fontName, width if fontSize == -1 else fontSize)
748 750
            font.setBold(True)
749 751

  
750
            x_factor = width / QFontMetricsF(font).height() #self.text()).height() / line_count)
752
            x_factor = width / QFontMetricsF(font).height() / line_count
751 753
            y_factor = height / self.text_width(font)
752 754
            factor = min(x_factor, y_factor)
753 755
            font.setPointSizeF(font.pointSizeF() * factor)
......
757 759
            font.setBold(True)
758 760

  
759 761
            x_factor = width / self.text_width(font)
760
            y_factor = height / QFontMetricsF(font).height() #self.text()).height() / line_count)
762
            y_factor = height / QFontMetricsF(font).height() / line_count
761 763
            factor = min(x_factor, y_factor)
762 764
            font.setPointSizeF(font.pointSizeF() * factor)
763 765
            self.setFont(font)
......
766 768
            font.setBold(True)
767 769

  
768 770
            x_factor = width / self.text_width(font)
769
            y_factor = height / QFontMetricsF(font).height() #.boun(self.text()).height() / line_count)
771
            y_factor = height / QFontMetricsF(font).height() / line_count
770 772
            factor = min(x_factor, y_factor)
771 773
            font.setPointSizeF(font.pointSizeF() * factor)
772 774
            self.setFont(font)
......
788 790
            x = self.loc[0]
789 791
            y = self.loc[1]
790 792
            rect = None
791
            line_count = self.text().count('\n') if self.text().count('\n') is not 0 else 1
793
            line_count = self.text().count('\n') + 1
792 794

  
793 795
            allowed_error = 0.01
794 796
            if abs(self.angle - 1.57) < allowed_error:
......
805 807
                font = QFont(fontName, width if fontSize == -1 else fontSize)
806 808
                font.setBold(True)
807 809

  
808
                x_factor = width / QFontMetricsF(font).height() #self.text()).height() / line_count)
810
                x_factor = width / QFontMetricsF(font).height() / line_count
809 811
                y_factor = height / self.text_width(font)
810 812
                factor = min(x_factor, y_factor)
811 813
                font.setPointSizeF(font.pointSizeF() * factor)
......
824 826
                font.setBold(True)
825 827

  
826 828
                x_factor = width / self.text_width(font)
827
                y_factor = height / QFontMetricsF(font).height() #self.text()).height() / line_count)
829
                y_factor = height / QFontMetricsF(font).height() / line_count
828 830
                factor = min(x_factor, y_factor)
829 831
                font.setPointSizeF(font.pointSizeF() * factor)
830 832
                self.setFont(font)
......
842 844
                font.setBold(True)
843 845

  
844 846
                x_factor = width / self.text_width(font)
845
                y_factor = height / QFontMetricsF(font).height() #.boun(self.text()).height() / line_count)
847
                y_factor = height / QFontMetricsF(font).height() / line_count
846 848
                factor = min(x_factor, y_factor)
847 849
                font.setPointSizeF(font.pointSizeF() * factor)
848 850
                self.setFont(font)
DTI_PID/DTI_PID/TextItemFactory.py
166 166
                elif sizeTextInfo:
167 167
                    item = QEngineeringSizeTextItem(mainSubSize=sizeTextInfo[1], sizeDelimiter=sizeTextInfo[2])
168 168
                    item.setToolTip('SIZE = {}'.format(sizeTextInfo[0]))
169
                    for i in sizeTextInfo[3]:
170
                        sizeTextInfo[0] = sizeTextInfo[0][:i] + '\n' + sizeTextInfo[0][i:]
169 171
                    item.setPlainText(sizeTextInfo[0])
170 172
                #elif self.isTagNoText(text):
171 173
                #    item = QEngineeringTagNoTextItem()
......
355 357
        from NominalPipeSize import NominalPipeSizeTable
356 358

  
357 359
        try:
360
            appDocData = AppDocData.instance()
361

  
358 362
            sizeUnit = None
359
            configs = AppDocData.instance().getConfigs('Project', 'Unit')
363
            configs = appDocData.getConfigs('Project', 'Unit')
360 364
            sizeUnit = configs[0].value if 1 == len(configs) else 'Imperial'
361 365

  
362 366
            pipe_sizes = NominalPipeSizeTable.instance().pipe_sizes
363 367

  
364 368
            text = text.replace("'", '"').replace(' ', '').upper()
365 369

  
370
            configs = appDocData.getConfigs('Line No', 'Newline')
371
            newline = False
372
            if configs:
373
                if int(configs[0].value) == 1:
374
                    newline = True
375

  
376
            # code for new line in line no
377
            index = []
378
            if newline:
379
                index = sorted(list(set([text.find('\n', i) for i in range(len(text)) if text.find('\n', i) != -1])), reverse=True)
380
            text = text.replace('\n', '')
381

  
366 382
            if delimiter != '/' and delimiter in text:
367 383
                if len([_text for _text in text.split(delimiter.upper()) if len(_text) > 0]) < 2:
368 384
                    return False
......
387 403
                second = split_text[1] if len(split_text) is 2 else None
388 404

  
389 405
            tokens = [first, second] if second is not None and len(second) is not 0 else [first]
390
            index = 0
406
            _index = 0
391 407
            for token in tokens:
392 408
                matches = [[(sizeData.find(token, sizeUnit) if sizeUnit else sizeData.find(token)), sizeData] for sizeData in pipe_sizes
393 409
                        if (sizeData.find(token, sizeUnit) if sizeUnit else sizeData.find(token))]
394 410
                if matches:
395
                    tokens[index] = matches[0]
411
                    tokens[_index] = matches[0]
396 412
                else:
397 413
                    return False
398
                index += 1
414
                _index += 1
399 415

  
400 416
            if len(tokens) == 2 and tokens[0][1].inch and tokens[1][1].inch:
401 417
                if tokens[0][1].inch < tokens[1][1].inch:
......
404 420
                if self.inch_to_number(tokens[0][0]) < self.inch_to_number(tokens[1][0]):
405 421
                    tokens[0], tokens[1] = tokens[1], tokens[0]
406 422

  
407
            return [delimiter.join([token[0] for token in tokens]), [token[0] for token in tokens], delimiter]
423
            return [delimiter.join([token[0] for token in tokens]), [token[0] for token in tokens], delimiter, index]
408 424
        except Exception as ex:
409 425
            from App import App
410 426
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,

내보내기 Unified diff

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