프로젝트

일반

사용자정보

개정판 85fb86be

ID85fb86bedabefbbe95cab5ad0e37ea3df68679c1
상위 cac5c0a9
하위 d21041d6, 87dafe67

함의성이(가) 5년 이상 전에 추가함

issue #589: flow mark before save load

Change-Id: I01b618d5f36d3895134e9ae93fb6e824166a3817

차이점 보기:

DTI_PID/DTI_PID/ConfigurationDialog.py
76 76
        self.ui.lineEditSizeDelimiter.setText(configs[0].value if 1 == len(configs) else 'X')
77 77
        configs = docData.getConfigs('Range', 'Detection Ratio')
78 78
        self.ui.doubleSpinBoxDetectionRange.setValue(float(configs[0].value)) if 1 == len(configs) else self.ui.doubleSpinBoxDetectionRange.setValue(2.5)
79
        configs = docData.getConfigs('Flow Mark', 'Position')
80
        self.ui.spinBoxFlowMarkPosition.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxFlowMarkPosition.setValue(100)
81
        configs = docData.getConfigs('Flow Mark', 'Length')
82
        self.ui.spinBoxFlowMarkLength.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxFlowMarkLength.setValue(200)
79 83

  
80 84
        configs = docData.getConfigs('Filter', 'MinimumSize')
81 85
        self.ui.spinBoxMinimumSize.setValue(int(configs[0].value)) if 1 == len(configs) else self.ui.spinBoxMinimumSize.setValue(30)
......
625 629
            
626 630
            configs.append(Config('Size', 'Delimiter', self.ui.lineEditSizeDelimiter.text()))
627 631
            configs.append(Config('Range', 'Detection Ratio', self.ui.doubleSpinBoxDetectionRange.value()))
632
            configs.append(Config('Flow Mark', 'Position', self.ui.spinBoxFlowMarkPosition.value()))
633
            configs.append(Config('Flow Mark', 'Length', self.ui.spinBoxFlowMarkLength.value()))
628 634
            configs.append(Config('Filter', 'MinimumSize', self.ui.spinBoxMinimumSize.value()))
629 635
            configs.append(Config('Small Object Size', 'Min Area', self.ui.spinBoxMinArea.value()))
630 636
            configs.append(Config('Small Object Size', 'Max Area', self.ui.spinBoxMaxArea.value()))
DTI_PID/DTI_PID/Configuration_UI.py
55 55
        self.doubleSpinBoxDetectionRange.setObjectName("doubleSpinBoxDetectionRange")
56 56
        self.horizontalLayout.addWidget(self.doubleSpinBoxDetectionRange)
57 57
        self.verticalLayout_3.addLayout(self.horizontalLayout)
58
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
59
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
60
        self.label_24 = QtWidgets.QLabel(self.groupBoxAttribute)
61
        self.label_24.setMaximumSize(QtCore.QSize(190, 16777215))
62
        self.label_24.setObjectName("label_24")
63
        self.horizontalLayout_5.addWidget(self.label_24)
64
        self.spinBoxFlowMarkPosition = QtWidgets.QSpinBox(self.groupBoxAttribute)
65
        self.spinBoxFlowMarkPosition.setMaximum(100)
66
        self.spinBoxFlowMarkPosition.setObjectName("spinBoxFlowMarkPosition")
67
        self.horizontalLayout_5.addWidget(self.spinBoxFlowMarkPosition)
68
        self.verticalLayout_3.addLayout(self.horizontalLayout_5)
69
        self.horizontalLayout_12 = QtWidgets.QHBoxLayout()
70
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
71
        self.label_26 = QtWidgets.QLabel(self.groupBoxAttribute)
72
        self.label_26.setMaximumSize(QtCore.QSize(220, 16777215))
73
        self.label_26.setObjectName("label_26")
74
        self.horizontalLayout_12.addWidget(self.label_26)
75
        self.spinBoxFlowMarkLength = QtWidgets.QSpinBox(self.groupBoxAttribute)
76
        self.spinBoxFlowMarkLength.setMinimum(1)
77
        self.spinBoxFlowMarkLength.setMaximum(99999)
78
        self.spinBoxFlowMarkLength.setObjectName("spinBoxFlowMarkLength")
79
        self.horizontalLayout_12.addWidget(self.spinBoxFlowMarkLength)
80
        self.verticalLayout_3.addLayout(self.horizontalLayout_12)
58 81
        self.gridLayout_6.addLayout(self.verticalLayout_3, 0, 0, 1, 1)
59 82
        self.gridLayout_2.addWidget(self.groupBoxAttribute, 1, 1, 1, 1)
60 83
        self.groupBox = QtWidgets.QGroupBox(self.Recognition)
......
513 536
        self.groupBoxAttribute.setTitle(_translate("ConfigurationDialog", "Attribute"))
514 537
        self.label_6.setText(_translate("ConfigurationDialog", "Size Delimiter : "))
515 538
        self.label_15.setText(_translate("ConfigurationDialog", "Attribute Detection Range(Ratio) : "))
539
        self.label_24.setText(_translate("ConfigurationDialog", "Line Flow Mark Position(Percent) : "))
540
        self.label_26.setText(_translate("ConfigurationDialog", "Line Flow Mark Minimum Line Length : "))
516 541
        self.groupBox.setTitle(_translate("ConfigurationDialog", "Line Detection"))
517 542
        self.label_4.setText(_translate("ConfigurationDialog", "Ignore Small Object Size : "))
518 543
        self.label_16.setText(_translate("ConfigurationDialog", "Small Line Minimum Length"))
DTI_PID/DTI_PID/LineNoTracer.py
548 548
                        end_break.transfer.onRemoved.connect(App.mainWnd().itemRemoved)
549 549
                        end_break.addSvgItemToScene(worker.graphicsView.scene)
550 550
        
551
        '''
552 551
        """make flow mark"""
552
        for line in lines:
553
            line.flowMark = None
554

  
555
        configs = docdata.getConfigs('Flow Mark')
556
        position = int(configs[0].value) if 2 == len(configs) else 100
557
        length = int(configs[1].value) if 2 == len(configs) else 200
558
        for lineNo in lineNos + docdata.tracerLineNos:
559
            lineNo.update_flow_mark(position, length)
560

  
561
        '''
553 562
        line_names = docdata.getSymbolListByType('type', 'Flow Mark')
554 563
        if len(line_names) is not 0:
555 564
                
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
48 48
            self.isCreated = True 
49 49

  
50 50
            self._owner = None
51
            self._flowMark = []
51
            self._flowMark = None
52 52
            self._lineType = 'Secondary'  # defulat line type is 'Secondary'
53 53
            self._properties = \
54 54
                {\
55
                    SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'):None\
55
                    SymbolProp(None, 'Size', 'Size Text Item', Expression='self.EvaluatedSize'):None,\
56
                    SymbolProp(None, 'Flow Mark', 'Size Text Item', Expression='self.EvaluatedSize'):None
56 57
                }
57 58

  
58 59
            self.setFlags(QGraphicsItem.ItemIsSelectable|QGraphicsItem.ItemIsFocusable)
......
96 97
        return str(self.uid)
97 98

  
98 99
    @property
100
    def flowMark(self):
101
        """ getter of flow mark """
102
        return self._flowMark
103

  
104
    @flowMark.setter
105
    def flowMark(self, value):
106
        self._flowMark = value
107

  
108
    @property
99 109
    def properties(self):
100
        """ getter of properties """
110
        """ getter of flow mark """
101 111
        import uuid
102 112

  
103 113
        for prop,value in self._properties.items():
......
1353 1363
        start = self.line().p1()
1354 1364
        end = self.line().p2()
1355 1365

  
1356
        _dir = [(end.x() - start.x())/self.length(), (end.y() - start.y())/self.length()]
1366
        dx = end.x() - start.x()
1367
        dy = end.y() - start.y()
1368
        _dir = [dx/self.length(), dy/self.length()]
1369

  
1370
        arrow_size = QEngineeringLineItem.ARROW_SIZE * 0.25
1371
        if self.flowMark:
1372
            arrow_size *= 2
1373
            end = QPointF(start.x() + dx * self.flowMark / 100, start.y() + dy * self.flowMark / 100)
1374

  
1357 1375
        perpendicular = (-_dir[1], _dir[0])
1358 1376
        polygon = QPolygonF()
1359
        polygon.append(QPointF(end.x() - _dir[0]*QEngineeringLineItem.ARROW_SIZE + perpendicular[0]*QEngineeringLineItem.ARROW_SIZE*0.25, 
1360
                            end.y() - _dir[1]*QEngineeringLineItem.ARROW_SIZE + perpendicular[1]*QEngineeringLineItem.ARROW_SIZE*0.25))
1361
        polygon.append(QPointF(end.x() - _dir[0]*QEngineeringLineItem.ARROW_SIZE - perpendicular[0]*QEngineeringLineItem.ARROW_SIZE*0.25, 
1362
                            end.y() - _dir[1]*QEngineeringLineItem.ARROW_SIZE - perpendicular[1]*QEngineeringLineItem.ARROW_SIZE*0.25))
1377
        polygon.append(QPointF(end.x() - _dir[0]*QEngineeringLineItem.ARROW_SIZE + perpendicular[0]*arrow_size, 
1378
                            end.y() - _dir[1]*QEngineeringLineItem.ARROW_SIZE + perpendicular[1]*arrow_size))
1379
        polygon.append(QPointF(end.x() - _dir[0]*QEngineeringLineItem.ARROW_SIZE - perpendicular[0]*arrow_size, 
1380
                            end.y() - _dir[1]*QEngineeringLineItem.ARROW_SIZE - perpendicular[1]*arrow_size))
1363 1381
        polygon.append(end)
1364 1382
        polygon.append(polygon[0])  # close polygon
1365 1383

  
......
1368 1386
        else:
1369 1387
            self._arrow.setPolygon(polygon)
1370 1388

  
1371
        self._arrow.setBrush(Qt.blue)
1389
        if self.flowMark:
1390
            self._arrow.setBrush(Qt.red)
1391
        else:
1392
            self._arrow.setBrush(Qt.blue)
1372 1393
        self._arrow.update()
1373 1394

  
1374 1395
        '''
......
1395 1416
        self.setLine(start[0], start[1], end[0], end[1])
1396 1417
        self.update()
1397 1418

  
1419
        tooltip = '<b>{}</b><br>({},{})-({},{})'.format(str(self.uid), start[0], start[1], end[0], end[1])
1420
        self.setToolTip(tooltip)
1421

  
1398 1422
        self.update_arrow()
1399 1423

  
1400 1424
    '''
DTI_PID/DTI_PID/Shapes/EngineeringLineNoTextItem.py
131 131
        if event.key() == Qt.Key_C:
132 132
            self.reverse()
133 133

  
134
    def update_flow_mark(self, position, minLength):
135
        """ update line flow mark """
136
        import math
137
        from EngineeringLineItem import QEngineeringLineItem
138

  
139
        allowed_error = 0.09
140

  
141
        try:
142
            for run in self.runs:
143
                pre = None
144
                preDir = None
145
                preRadian = None
146
                for item in run.items:
147
                    if pre is None and type(item) is QEngineeringLineItem and (item._lineType == 'Primary' or item._lineType == 'Secondary') and item.length() > minLength:
148
                        pre = item
149
                        start = item.line().p1()
150
                        end = item.line().p2()
151
                        _dir = [(end.x() - start.x())/item.length(), (end.y() - start.y())/item.length()]
152
                        radian = math.atan2(_dir[0], _dir[1]) - math.pi / 2
153
                        preDir = _dir
154
                        preRadian = radian if radian >= 0 else radian + 2 * math.pi
155
                        preRadian = abs(preRadian - math.pi)
156
                        continue
157
                    elif pre and type(item) is QEngineeringLineItem and (item._lineType == 'Primary' or item._lineType == 'Secondary'):
158
                        start = item.line().p1()
159
                        end = item.line().p2()
160
                        _dir = [(end.x() - start.x())/item.length(), (end.y() - start.y())/item.length()]
161
                        radian = math.atan2(_dir[0], _dir[1]) - math.pi / 2
162
                        currRadian = radian if radian >= 0 else radian + 2 * math.pi
163
                        currRadian = abs(currRadian - math.pi)
164
                        if abs(currRadian - preRadian) > allowed_error:
165
                            # insert flow mark at pre line
166
                            if pre.length() > minLength:
167
                                #if str(pre.uid) == '62edfbe5-29fd-49af-840b-6dce051e04d1':
168
                                    #print(math.atan2(preDir[0], preDir[1]) - math.pi / 2)
169
                                    #print(currRadian)
170
                                    #print(preRadian)
171
                                pre.flowMark = position
172
                                pre.update_arrow()
173

  
174
                            pre = item
175
                            preDir = _dir
176
                            preRadian = currRadian
177
            
178
                if pre and type(item) is QEngineeringLineItem and (item._lineType == 'Primary' or item._lineType == 'Secondary') and item.length() > minLength:
179
                    pre.flowMark = position
180
                    pre.update_arrow()
181

  
182
        except Exception as ex:
183
            from App import App 
184
            from AppDocData import MessageType
185

  
186
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
187
            App.mainWnd().addMessage.emit(MessageType.Error, message)
188

  
134 189
    """
135 190
    def paint(self, painter, options=None, widget=None):
136 191
        QEngineeringTextItem.paint(self, painter, options, widget)
DTI_PID/DTI_PID/SymbolAttrEditorDialog.py
238 238
    '''
239 239
    def onDelAttr(self):
240 240
        model = self.ui.tableWidgetAttr.model()
241
        #row = self.ui.tableWidgetAttr.currentRow()
241
        row = self.ui.tableWidgetAttr.currentRow()
242 242
        
243 243
        #if row != -1 and not self.ui.tableWidgetAttr.item(row, 1).tag.IsProp:
244 244
        model.removeRow(row)
DTI_PID/DTI_PID/UI/Configuration.ui
91 91
              </item>
92 92
             </layout>
93 93
            </item>
94
            <item>
95
             <layout class="QHBoxLayout" name="horizontalLayout_5">
96
              <item>
97
               <widget class="QLabel" name="label_24">
98
                <property name="maximumSize">
99
                 <size>
100
                  <width>190</width>
101
                  <height>16777215</height>
102
                 </size>
103
                </property>
104
                <property name="text">
105
                 <string>Line Flow Mark Position(Percent) : </string>
106
                </property>
107
               </widget>
108
              </item>
109
              <item>
110
               <widget class="QSpinBox" name="spinBoxFlowMarkPosition">
111
                <property name="maximum">
112
                 <number>100</number>
113
                </property>
114
               </widget>
115
              </item>
116
             </layout>
117
            </item>
118
            <item>
119
             <layout class="QHBoxLayout" name="horizontalLayout_12">
120
              <item>
121
               <widget class="QLabel" name="label_26">
122
                <property name="maximumSize">
123
                 <size>
124
                  <width>220</width>
125
                  <height>16777215</height>
126
                 </size>
127
                </property>
128
                <property name="text">
129
                 <string>Line Flow Mark Minimum Line Length : </string>
130
                </property>
131
               </widget>
132
              </item>
133
              <item>
134
               <widget class="QSpinBox" name="spinBoxFlowMarkLength">
135
                <property name="minimum">
136
                 <number>1</number>
137
                </property>
138
                <property name="maximum">
139
                 <number>99999</number>
140
                </property>
141
               </widget>
142
              </item>
143
             </layout>
144
            </item>
94 145
           </layout>
95 146
          </item>
96 147
         </layout>

내보내기 Unified diff

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