프로젝트

일반

사용자정보

개정판 e8f57e0a

IDe8f57e0a595eefd2dc810784ad1fab9af0596677
상위 2374ffa5
하위 5b3801e5

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

issue #1059: Remove unnecessary package

Change-Id: I66f722b3735821a613250631646ad5831b3e72f1

차이점 보기:

HYTOS/HYTOS/MainWindow.py
1565 1565

  
1566 1566
            if image_path:
1567 1567
                self.on_view_connector(False)  # hide connector
1568
                self.graphicsView.save_as_image(image_path)
1568
                self.graphicsView.save_as_image(image_path)  # try to use save_as_svg when will generate svg file
1569 1569

  
1570 1570
                workspace = self.get_work_space()
1571 1571
                file_name = os.path.join(workspace, app_doc_data.activeDrawing.name + '.xlsx')
......
1595 1595
                        ws = wb.copy_worksheet(wb.get_sheet_by_name('Page'))
1596 1596
                        ws.title = f"Page ({page_no})"
1597 1597

  
1598
                        cal_image = openpyxl.drawing.image.Image(image_path)
1599
                        # rect = self.graphicsView.sceneRect()
1598
                        cal_image = openpyxl.drawing.image.Image(image_path)  # TODO: try to insert svg file instead of image
1600 1599
                        x_scale = MainWindow.PAPER_SIZE.width() / cal_image.width
1601 1600
                        y_scale = MainWindow.PAPER_SIZE.height() / cal_image.height
1602 1601
                        cal_image.width *= x_scale
HYTOS/HYTOS/QtImageViewer.py
573 573
    def save_as_svg(self, file_path):
574 574
        """ save scene as given file """
575 575
        from xml.etree.ElementTree import Element, tostring, SubElement, dump, ElementTree, parse
576
        from PyQt5.QtSvg import QSvgGenerator
577
        import cairosvg
578 576

  
579 577
        def prettify(elem):
580 578
            """Return a pretty-printed XML string for the Element."""
......
588 586
            except Exception as ex:
589 587
                from AppDocData import MessageType
590 588

  
591
                message = 'error occurred({}) in {}:{}'.format(repr(ex), sys.exc_info()[-1].tb_frame.f_code.co_filename,
592
                                                               sys.exc_info()[-1].tb_lineno)
589
                message = f'error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \
590
                          f'{sys.exc_info()[-1].tb_lineno}'
593 591
                self.display_message.emit(MessageType.Error, message)
594 592

  
595 593
        try:
......
613 611

  
614 612
            with open(file_path, 'w', encoding='utf-8') as output_file:
615 613
                output_file.write(prettify(svg))
616

  
617
            cairosvg.svg2png(url=file_path, write_to="d:\\temp\\temp.png")
618

  
619

  
620
            """
621
            generator = QSvgGenerator()
622
            generator.setFileName(file_path)
623
            default = QSize(1550, 990)
624
            generator.setSize(default)
625

  
626
            painter = QPainter()
627
            # render the scene
628
            painter.begin(generator)
629
            self.render(painter)
630
            painter.end()
631
            """
632

  
633
            # save the image to a given file
634
            # image.save(file_path)
635 614
        except Exception as ex:
636 615
            from App import App
637 616
            from AppDocData import MessageType

내보내기 Unified diff

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