프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / DTI_PID / Shapes / QEngineeringTrimLineNoTextItem.py @ f28a350a

이력 | 보기 | 이력해설 | 다운로드 (3.03 KB)

1
# coding: utf-8
2
"""
3
This is engineering trim line no text item module
4
"""
5

    
6
import os.path
7
import sys
8
import copy
9
try:
10
    from PyQt5.QtCore import Qt, QPointF, QRectF, pyqtSignal, QT_VERSION_STR, QRect
11
    from PyQt5.QtGui import QImage, QPixmap, QPainterPath, QBrush, QPen, QTransform, QFont
12
    from PyQt5.QtWidgets import QGraphicsView, QGraphicsScene, QFileDialog, QGraphicsItem, QAbstractGraphicsShapeItem, QGraphicsTextItem
13
except ImportError:
14
    try:
15
        from PyQt4.QtCore import Qt, QRectF, pyqtSignal, QT_VERSION_STR, QRect
16
        from PyQt4.QtGui import QGraphicsView, QGraphicsScene, QImage, QPixmap, QPainterPath, QFileDialog, QFont
17
    except ImportError:
18
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
19

    
20
from EngineeringPolylineItem import QEngineeringPolylineItem
21
from GraphicsBoundingBoxItem import QGraphicsBoundingBoxItem
22
import OcrResultDialog
23
from AppDocData import AppDocData
24
from EngineeringLineNoTextItem import QEngineeringLineNoTextItem
25

    
26
class QEngineeringTrimLineNoTextItem(QEngineeringLineNoTextItem):
27
    """
28
    This is engineering trim line no text item class
29
    """
30

    
31
    '''
32
    '''
33
    def __init__(self, parent=None):
34
        import uuid
35
        
36
        QEngineeringLineNoTextItem.__init__(self, parent)
37
        self.loc = (0, 0)
38
        self.size = (1, 1)
39
        self.angle = 0
40
        self.setPlainText('')
41
        self.setVisible(True)
42

    
43
    '''
44
        @brief      generate xml code
45
        @author     humkyung
46
        @date       2018.06.09
47
    '''
48
    def toXml(self):
49
        from xml.etree.ElementTree import Element, SubElement, dump, ElementTree
50
        from EngineeringLineItem import QEngineeringLineItem
51
        from SymbolSvgItem import SymbolSvgItem
52

    
53
        try:
54
            node = Element('TRIM_LINE_NO')
55
            uidNode = Element('UID')
56
            uidNode.text = str(self.uid)
57
            node.append(uidNode)
58

    
59
            for run in self.runs:
60
                node.append(run.toXml())
61
        except Exception as ex:
62
            return None
63

    
64
        return node
65

    
66
    def toSql(self):
67
        """ generate sql phrase to save to database """
68
        import uuid
69

    
70
        res = []
71

    
72
        app_doc_data = AppDocData.instance()
73
        cols = ['UID', 'Drawings_UID', 'Symbol_UID']
74
        rect = self.sceneBoundingRect()
75
        values = ['?', '?', "(select UID from Symbol where Name='Trim Line NO' and SymbolType_UID=-1)"]
76
        params = [(str(self.uid), str(app_doc_data.activeDrawing.UID))]
77
        sql = 'insert into Components({}) values({})'.format(','.join(cols), ','.join(values))
78
        res.append((sql, tuple(params)))
79

    
80
        _index = 1
81
        for run in self.runs:
82
            res.extend(run.to_sql(_index, self))
83
            _index += 1
84

    
85
        return res
86

    
87
    def explode(self, dummy=None):
88
        from App import App 
89
        super().explode()
90
        treeWidget = App.mainWnd().itemTreeWidget
91
        treeWidget.findItemByData(self).parent().removeChild(treeWidget.findItemByData(self))
92
        tracerLineNos = AppDocData.instance().tracerLineNos
93
        tracerLineNos.pop(tracerLineNos.index(self))
클립보드 이미지 추가 (최대 크기: 500 MB)