프로젝트

일반

사용자정보

개정판 0d802026

ID0d802026c0d55517af621339326c970585c29adf
상위 e9d9cab4
하위 e08d45f9

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

issue #1273: able to move label of nozzle

Change-Id: I261a9aa68c059b68680505f05b422471c3c8a057

차이점 보기:

HYTOS/HYTOS/Shapes/SymbolSvgItem.py
261 261
                index += 1
262 262
            # up to here
263 263

  
264
            '''
265
            # Output Pump, Compressor, Control Valve
266
            if self.has_attribute():
267
                attr = self.attribute
268
                for key, value in attr.items():
269
                    if key == 'Tag_No':
270
                        continue
271
                    cols = ['UID', 'Components_UID', 'Key', 'Value']
272
                    values = ['?', '?', '?', '?']
273
                    param = [str(uuid.uuid4()), str(self.uid), key, value]
274
                    sql = 'insert or replace into Result({}) values({})'.format(','.join(cols), ','.join(values))
275
                    res.append((sql, tuple(param)))
276
            '''
264
            # save nozzle label
265
            for conn, label in self.desc_labels.items():
266
                res.extend(label.toSql(conn))
267
            # up to here
277 268

  
278 269
        except Exception as ex:
279 270
            from App import App
......
367 358

  
368 359
        res = None
369 360

  
370
        label_rect = label.boundingRect()
371
        conn_rect = conn.mapRectFromParent(conn.boundingRect())
372
        dx, dy = conn.dir()
373

  
374
        if dx == 1:
375
            res = QPointF(conn_rect.x() + conn_rect.width() * 0.5, conn_rect.y())
376
        elif dy == -1:
377
            res = QPointF(conn_rect.x() + conn_rect.width()*0.5, conn_rect.y() - label_rect.height())
378
        elif dy == 1:
379
            res = QPointF(conn_rect.x() + conn_rect.width()*0.5, conn_rect.y() + conn_rect.height()*0.5)
380
        elif dx == -1:
381
            res = QPointF(conn_rect.x() - label_rect.width(), conn_rect.y() + conn_rect.height()*0.5)
361
        app_doc_data = AppDocData.instance()
362
        if conn.data.pos:
363
            res = QPointF(conn.data.pos[0], conn.data.pos[1])
364
        else:
365
            label_rect = label.boundingRect()
366
            conn_rect = conn.mapRectFromParent(conn.boundingRect())
367
            dx, dy = conn.dir()
368

  
369
            if dx == 1:
370
                res = QPointF(conn_rect.x() + conn_rect.width() * 0.5, conn_rect.y())
371
            elif dy == -1:
372
                res = QPointF(conn_rect.x() + conn_rect.width()*0.5, conn_rect.y() - label_rect.height())
373
            elif dy == 1:
374
                res = QPointF(conn_rect.x() + conn_rect.width()*0.5, conn_rect.y() + conn_rect.height()*0.5)
375
            elif dx == -1:
376
                res = QPointF(conn_rect.x() - label_rect.width(), conn_rect.y() + conn_rect.height()*0.5)
382 377

  
383 378
        return res
384 379

  
......
402 397
                        f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
403 398
                        f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
404 399

  
405
                    label_rect = self.desc_labels[conns[0]].boundingRect()
406
                    self.desc_labels[conns[0]].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
407
                '''    
408
                for conn in self.connectors:
409
                    if self.tag_no:
410
                        if conn.data:
411
                            self.desc_labels[conn].setHtml(
412
                                f"{self.tag_no}<br>{convert_to_fixed_point(conn.data.pressure_drop)} {units['Pressure']}<br>"
413
                                f"{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
414

  
415
                            pos = self.get_label_pos_of_connector(conn, self.desc_labels[conn])
416
                            self.desc_labels[conn].setPos(pos)
417
                '''
400
                    pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
401
                    self.desc_labels[conns[0]].setPos(pos)
418 402
            elif self.type == 'Filter':
419 403
                if self.tag_no:
420 404
                    conns = [conn for conn in self.connectors if conn.data and conn.data.elevation is not None]
......
423 407
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
424 408
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
425 409

  
426
                        label_rect = self.desc_labels[conns[0]].boundingRect()
427
                        self.desc_labels[conns[0]].setPos(
428
                            QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
429
                    '''    
430
                    for conn in self.connectors:
431
                        if conn.data:
432
                            conn_rect = conn.boundingRect()
433
                            self.desc_labels[conn].setHtml(
434
                                f"{self.tag_no}<br>{convert_to_fixed_point(conn.data.pressure_drop)} {units['Pressure']}<br>"
435
                                f"{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
436

  
437
                            pos = self.get_label_pos_of_connector(conn, self.desc_labels[conn])
438
                            self.desc_labels[conn].setPos(QPointF(conn_rect.width(), 0))
439
                    '''
410
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
411
                        self.desc_labels[conns[0]].setPos(pos)
440 412
            elif self.type == 'Heat Exchanger':
441 413
                if self.tag_no:
442 414
                    nozzles = []
......
587 559
                                f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
588 560
                                f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
589 561

  
590
                            label_rect = self.desc_labels[conns[0]].boundingRect()
591
                            self.desc_labels[conns[0]].setPos(
592
                                QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
593
                        '''
594
                        for conn in self.connectors:
595
                            if conn.data:
596
                                conn_rect = conn.boundingRect()
597
                                self.desc_labels[conn].setHtml(
598
                                    f"{self.tag_no}<br>{convert_to_fixed_point(conn.data.pressure_drop)} {units['Pressure']}<br>"
599
                                    f"{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
600

  
601
                                pos = self.get_label_pos_of_connector(conn, self.desc_labels[conn])
602
                                self.desc_labels[conn].setPos(pos)
603
                        '''
562
                            pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
563
                            self.desc_labels[conns[0]].setPos(pos)
604 564
                elif self.name == 'M_DP_E':
605 565
                    if self.tag_no:
606 566
                        nozzles = []
......
619 579
                                self.desc_labels[self.connectors[0]].setPos(
620 580
                                    QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
621 581

  
622
                                pos = self.get_label_pos_of_connector(self.connectors[2],
623
                                                                      self.desc_labels[self.connectors[2]])
582
                                pos = self.get_label_pos_of_connector(self.connectors[0],
583
                                                                      self.desc_labels[self.connectors[0]])
624 584
                                self.desc_labels[self.connectors[0]].setPos(pos)
625 585
                            elif 'N1' in nozzles:
626 586
                                self.desc_labels[self.connectors[0]].setHtml(
627 587
                                    f"{self.tag_no}<br>[V] : {convert_to_fixed_point(self.connectors[0].data.pressure_drop)} {units['Pressure']}<br>"
628 588
                                    f"[V] : {convert_to_fixed_point(self.connectors[0].data.elevation)} {units['Length']}")
629 589

  
630
                                pos = self.get_label_pos_of_connector(self.connectors[2],
631
                                                                      self.desc_labels[self.connectors[2]])
590
                                pos = self.get_label_pos_of_connector(self.connectors[0],
591
                                                                      self.desc_labels[self.connectors[0]])
632 592
                                self.desc_labels[self.connectors[0]].setPos(pos)
633 593
                            elif 'N2' in nozzles:
634 594
                                self.desc_labels[self.connectors[1]].setHtml(
......
638 598
                                pos = self.get_label_pos_of_connector(self.connectors[2],
639 599
                                                                      self.desc_labels[self.connectors[2]])
640 600
                                self.desc_labels[self.connectors[1]].setPos(pos)
641
                        '''
642
                        conns = [conn for conn in self.connectors
643
                                if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
644
                        if conns:
645
                            self.desc_labels[conns[0]].setHtml(
646
                                f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} {units['Pressure']}"
647
                                f"<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
648

  
649
                            label_rect = self.desc_labels[conns[0]].boundingRect()
650
                            self.desc_labels[conns[0]].setPos(
651
                                QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
652
                        '''
653 601
                elif self.name == 'M_React':
654 602
                    if self.tag_no:
655 603
                        nozzles = []
......
679 627
                                    f"[Top] : {convert_to_fixed_point(self.connectors[top_index].data.elevation)} {units['Length']}<br>"
680 628
                                    f"[Btm] : {convert_to_fixed_point(self.connectors[btm_index].data.elevation)} {units['Length']}")
681 629

  
682
                                pos = self.get_label_pos_of_connector(self.connectors[3],
683
                                                                      self.desc_labels[self.connectors[3]])
630
                                pos = self.get_label_pos_of_connector(self.connectors[top_index],
631
                                                                      self.desc_labels[self.connectors[top_index]])
684 632
                                self.desc_labels[self.connectors[top_index]].setPos(pos)
685 633

  
686 634
                            elif 'N1' in nozzles or 'N2' in nozzles or 'N6' in nozzles:
......
695 643
                                    f"[DP] : {convert_to_fixed_point(self.connectors[index].data.pressure_drop)} {units['Pressure']}<br>"
696 644
                                    f"[Top] : {convert_to_fixed_point(self.connectors[index].data.elevation)} {units['Length']}")
697 645

  
698
                                pos = self.get_label_pos_of_connector(self.connectors[3],
699
                                                                      self.desc_labels[self.connectors[3]])
646
                                pos = self.get_label_pos_of_connector(self.connectors[index],
647
                                                                      self.desc_labels[self.connectors[index]])
700 648
                                self.desc_labels[self.connectors[index]].setPos(pos)
701 649

  
702 650
                            elif 'N3' in nozzles or 'N4' in nozzles or 'N5' in nozzles:
......
711 659
                                    f"[DP] : {convert_to_fixed_point(self.connectors[index].data.pressure_drop)} {units['Pressure']}<br>"
712 660
                                    f"[Btm] : {convert_to_fixed_point(self.connectors[index].data.elevation)} {units['Length']}")
713 661

  
714
                                pos = self.get_label_pos_of_connector(self.connectors[3],
715
                                                                      self.desc_labels[self.connectors[3]])
662
                                pos = self.get_label_pos_of_connector(self.connectors[index],
663
                                                                      self.desc_labels[self.connectors[index]])
716 664
                                self.desc_labels[self.connectors[index]].setPos(pos)
717

  
718
                        '''
719
                        conns = [conn for conn in self.connectors
720
                                if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
721
                        if conns:
722
                            self.desc_labels[conns[0]].setHtml(
723
                                f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} {units['Pressure']}"
724
                                f"<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
725

  
726
                            label_rect = self.desc_labels[conns[0]].boundingRect()
727
                            self.desc_labels[conns[0]].setPos(
728
                                QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
729
                        '''
730 665
            elif self.type == 'Strainer':
731 666
                if self.tag_no:
732 667
                    conns = [conn for conn in self.connectors
......
736 671
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} {units['Pressure']}<br>"
737 672
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
738 673

  
739
                        label_rect = self.desc_labels[conns[0]].boundingRect()
740
                        self.desc_labels[conns[0]].setPos(
741
                            QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
674
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
675
                        self.desc_labels[conns[0]].setPos(pos)
742 676
        elif self.category == 'Equipment - [ Pressurized ]':
743 677
            if self.type == 'Battery Limit':
744 678
                if self.tag_no:
......
749 683
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure)} {units['Pressure']}(g)<br>"
750 684
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
751 685

  
752
                        label_rect = self.desc_labels[conns[0]].boundingRect()
753
                        self.desc_labels[conns[0]].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
686
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
687
                        self.desc_labels[conns[0]].setPos(pos)
754 688
            elif self.type == 'Column':
755 689
                if self.tag_no:
756 690
                    for conn in self.connectors:
......
818 752
                                f"{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
819 753
                                f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
820 754

  
821
                            label_rect = self.desc_labels[conns[0]].boundingRect()
822
                            self.desc_labels[conns[0]].setPos(
823
                                QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
755
                            pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
756
                            self.desc_labels[conns[0]].setPos(pos)
824 757
            elif self.type == 'Pump':
825 758
                if self.tag_no:
826 759
                    conns = [conn for conn in self.connectors if conn.data and conn.data.elevation is not None]
......
830 763
                            f"{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
831 764
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
832 765

  
833
                        label_rect = self.desc_labels[conns[0]].boundingRect()
834
                        self.desc_labels[conns[0]].setPos(
835
                            QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
766
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
767
                        self.desc_labels[conns[0]].setPos(pos)
836 768
        elif self.category == 'Instrument':
837 769
            if self.type == 'Flowmeter':
838 770
                if self.tag_no:
......
842 774
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} "
843 775
                            f"{units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
844 776

  
845
                        label_rect = self.desc_labels[self.connectors[0]].boundingRect()
846
                        self.desc_labels[self.connectors[0]].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
777
                        pos = self.get_label_pos_of_connector(self.connectors[0], self.desc_labels[self.connectors[0]])
778
                        self.desc_labels[self.connectors[0]].setPos(pos)
847 779
            elif self.type == 'Line Splitter':
848 780
                if self.tag_no:
849 781
                    conns = [conn for conn in self.connectors
......
853 785
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} "
854 786
                            f"{units['Pressure']}<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
855 787

  
856
                        label_rect = self.desc_labels[conns[0]].boundingRect()
857
                        self.desc_labels[conns[0]].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
788
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
789
                        self.desc_labels[conns[0]].setPos(pos)
858 790
            elif self.type == 'Reducer':
859 791
                if self.tag_no:
860 792
                    conns = [conn for conn in self.connectors
......
864 796
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} "
865 797
                            f"{units['Pressure']}<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
866 798

  
867
                        label_rect = self.desc_labels[conns[0]].boundingRect()
868
                        self.desc_labels[conns[0]].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
799
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
800
                        self.desc_labels[conns[0]].setPos(pos)
869 801
            elif self.type == 'Valve':
870 802
                if self.tag_no and self.name in ('CV_H', 'CV_V'):
871 803
                    conns = [conn for conn in self.connectors if conn.data and conn.data.elevation is not None]
......
874 806
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
875 807
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
876 808

  
877
                        label_rect = self.desc_labels[conns[0]].boundingRect()
878
                        self.desc_labels[conns[0]].setPos(QPointF((rect.width() - label_rect.width())*0.5, rect.height()))
809
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
810
                        self.desc_labels[conns[0]].setPos(pos)
879 811
                elif self.tag_no and self.name in ('MV_H', 'MV_V'):
880 812
                    conns = [conn for conn in self.connectors
881 813
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
......
884 816
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} "
885 817
                            f"{units['Pressure']}<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
886 818

  
887
                        label_rect = self.desc_labels[conns[0]].boundingRect()
888
                        self.desc_labels[conns[0]].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
819
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[conns[0]])
820
                        self.desc_labels[conns[0]].setPos(pos)
889 821

  
890 822
        font_size = None
891 823
        configs = app_doc_data.getAppConfigs('option', 'TagFontSize')

내보내기 Unified diff

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