프로젝트

일반

사용자정보

개정판 2909e094

ID2909e09445acd85dd875647bae31acad4a95b457
상위 8fc98368
하위 3a9d8155

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

fixed issue #563: 연결된 Component를 기준으로 라인 타입을 인식한다

Change-Id: I45be3e69a9fb5eae48acdda07b7c3970f3642695

차이점 보기:

DTI_PID/DTI_PID/ConfigurationDialog.py
1 1
# coding: utf-8
2
"""
3
This is Configuratio dialog module
4
"""
2
""" This is Configuratio dialog module """
5 3

  
6 4
import os
7 5
import sys
......
142 140
        configs = docData.getConfigs('LineTypes')
143 141

  
144 142
        lineTypes = docData.getLineTypes()
145
        self.ui.tableWidgetLineTypes.setColumnCount(5)
146
        self.ui.tableWidgetLineTypes.setHorizontalHeaderLabels(['Name', 'Color', 'Width', 'Style', 'Opacity'])
143
        self.ui.tableWidgetLineTypes.setColumnCount(6)
144
        self.ui.tableWidgetLineTypes.setHorizontalHeaderLabels([self.tr('Name'), self.tr('Color'), self.tr('Width'), self.tr('Style'), self.tr('Opacity'), self.tr('Conditions')])
147 145
        self.ui.tableWidgetLineTypes.setRowCount(len(lineTypes))
148 146
        row = 0
149 147
        for lineType in lineTypes:
......
153 151

  
154 152
            matches = [config for config in configs if config.key == lineType]
155 153

  
156
            # Color
154
            """" Color """
157 155
            color_cell = QTableWidgetItem('')
158 156
            color_cell.setFlags(Qt.ItemIsEnabled)
159 157
            if matches:
......
163 161
                color_cell.setBackground(Qt.blue)
164 162
            self.ui.tableWidgetLineTypes.setItem(row, 1, color_cell)
165 163

  
166
            ### line width
164
            """ line width """
167 165
            lineWidthSpinBox = QSpinBox()
168 166
            lineWidthSpinBox.setRange(1, 25)
169 167
            lineWidthSpinBox.setSingleStep(1)
......
174 172
                lineWidthSpinBox.setValue(5)
175 173
            self.ui.tableWidgetLineTypes.setCellWidget(row, 2, lineWidthSpinBox)
176 174

  
177
            ## line style
175
            """ line style """
178 176
            lineStyleComboBox = QComboBox()
179 177
            lineStyleComboBox.addItems(['SolidLine', 'DashLine', 'DotLine', 'DashDotLine', 'DashDotDotLine', 'CustomDashLine'])
180 178
            if matches:
......
185 183
            lineStyleComboBox.setCurrentText(matches[0].value.split(',')[1]) if matches else lineStyleComboBox.setCurrentText('SolidLine')
186 184
            self.ui.tableWidgetLineTypes.setCellWidget(row, 3, lineStyleComboBox)
187 185

  
188
            ### line transparent 
186
            """ line transparent  """
189 187
            lineTransparentSpinBox = QSpinBox()
190 188
            lineTransparentSpinBox.setRange(10, 100)
191 189
            lineTransparentSpinBox.setSingleStep(10)
......
196 194
                lineTransparentSpinBox.setValue(100)
197 195
            self.ui.tableWidgetLineTypes.setCellWidget(row, 4, lineTransparentSpinBox)
198 196

  
197
            conditions_button = QPushButton()
198
            conditions_button.setText('...')
199
            self.ui.tableWidgetLineTypes.setCellWidget(row, 5, conditions_button)
200

  
199 201
            row += 1
200 202

  
201 203
        self.ui.tableWidgetLineTypes.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
DTI_PID/DTI_PID/ConnectAttrDialog.py
31 31
    displayMessage = pyqtSignal(str)
32 32
    updateProgress = pyqtSignal(int)
33 33

  
34
    def __init__(self, graphicsView):
34
    def __init__(self, graphicsView, update_line_type):
35 35
        QThread.__init__(self)
36 36
        self.graphicsView = graphicsView
37
        self._update_line_type = update_line_type
37 38

  
38 39
    '''
39 40
        @brief  execute connecting attributes
......
44 45
        from LineNoTracer import connectAttrImpl
45 46

  
46 47
        try:
47
            connectAttrImpl(self)
48
            connectAttrImpl(self, self._update_line_type)
48 49
        except Exception as ex:
49 50
            from App import App 
50 51
            message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
......
131 132
            self.ui.buttonBox.setDisabled(True)
132 133

  
133 134
            # 1 - create Worker and Thread inside the Form
134
            self.obj = Worker(self.graphicsView)  # no parent!
135
            #self.obj.graphicsView = self.graphicsView
136
            #self.thread = QThread()  # no parent!
135
            self.obj = Worker(self.graphicsView, self.ui.checkBoxUpdateLineType.isChecked())
137 136

  
138
            # 2 - Move the Worker object to the Thread object
139
            #self.obj.moveToThread(self.thread)
140

  
141
            # 3 - Connect Worker Signals to the Thread slots
142
            #self.obj.finished.connect(self.obj.quit)
137
            # 2 - Connect Worker Signals to the Thread slots
143 138
            self.obj.displayMessage.connect(self.addListItem)
144 139
            self.obj.updateProgress.connect(self.updateProgress)
145 140

  
146
            # 4 - Connect Thread started signal to Worker operational slot method
147
            #self.thread.started.connect(self.obj.procCounter)
148
        
149
            # 5 - Thread finished signal will close the app if you want!
141
            # 3 - Thread finished signal will close the app if you want!
150 142
            self.obj.finished.connect(self.dlgExit)
151 143

  
152
            # 6 - Start the thread
144
            # 4 - Start the thread
153 145
            self.obj.start()
154 146

  
155 147
            self.tmStart = timeit.default_timer()
DTI_PID/DTI_PID/ConnectAttr_UI.py
41 41
        self.gridLayout.addLayout(self.horizontalLayout, 6, 0, 1, 1)
42 42
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
43 43
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
44
        self.checkBoxUpdateLineType = QtWidgets.QCheckBox(ConnectAttr)
45
        self.checkBoxUpdateLineType.setObjectName("checkBoxUpdateLineType")
46
        self.horizontalLayout_2.addWidget(self.checkBoxUpdateLineType)
44 47
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
45 48
        self.horizontalLayout_2.addItem(spacerItem)
46 49
        self.pushButtonStart = QtWidgets.QPushButton(ConnectAttr)
......
61 64
    def retranslateUi(self, ConnectAttr):
62 65
        _translate = QtCore.QCoreApplication.translate
63 66
        ConnectAttr.setWindowTitle(_translate("ConnectAttr", "Connect Attribute"))
67
        self.checkBoxUpdateLineType.setText(_translate("ConnectAttr", "Update Line Type"))
64 68
        self.pushButtonStart.setText(_translate("ConnectAttr", "Start"))
65 69

  
DTI_PID/DTI_PID/LineNoTracer.py
405 405
    @history    humkyung 2018.06.21 paste connect attributes codes from recognizeLine function
406 406
                kyouho  2018.09.14  clear Item's owner 
407 407
'''
408
def connectAttrImpl(worker):
408
def connectAttrImpl(worker, update_line_type):
409 409
    from LineNoTracer import LineNoTracer
410 410
    from AppDocData import AppDocData
411 411
    from EngineeringSpecBreakItem import QEngineeringSpecBreakItem
......
471 471
            valve.connectAttribute(labels, clear=False)
472 472

  
473 473
        """ update line type """
474
        lines = [line for line in worker.graphicsView.scene.items() if type(line) is QEngineeringLineItem]
475
        for line in lines: line.update_line_type()
474
        if update_line_type == True:
475
            print(update_line_type)
476
            lines = [line for line in worker.graphicsView.scene.items() if type(line) is QEngineeringLineItem]
477
            for line in lines: line.update_line_type()
476 478

  
477 479
        """make line end break"""
478 480
        end_breaks = []
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
944 944
    '''
945 945
    def update_line_type(self):
946 946
        import uuid
947
        from EngineeringInstrumentItem import QEngineeringInstrumentItem
948 947

  
949 948
        try:
949
            pool,visited,items = [self],[],[]
950
            while pool:
951
                obj = pool.pop()
952
                visited.append(obj)
953

  
954
                """ connected items """
955
                connected = [connector.connectedItem for connector in obj.connectors if connector.connectedItem and not type(connector.connectedItem) is uuid.UUID]
956
                """ connected lines at point """
957
                lines = [connector.connectedItem for connector in obj.connectors if connector.connectedItem and type(connector.connectedItem) is QEngineeringLineItem and connector._connected_at == QEngineeringAbstractItem.CONNECTED_AT_PT]
958
                """ add items not in 'connected' to items list """
959
                items.extend([item for item in connected if item not in lines])
960
                """ add items not visited to pool """
961
                pool.extend([item for item in lines if item not in visited])
962

  
950 963
            for condition in QEngineeringLineItem.LINE_TYPE_CONDITIONS:
951
                items = [connector.connectedItem for connector in self.connectors if connector.connectedItem and not type(connector.connectedItem) is uuid.UUID]
952 964
                if condition.eval(items):
953 965
                    self._lineType = condition.line_type
954 966
                    break
DTI_PID/DTI_PID/UI/dlgConnectAttr.ui
58 58
   <item row="2" column="0">
59 59
    <layout class="QHBoxLayout" name="horizontalLayout_2">
60 60
     <item>
61
      <widget class="QCheckBox" name="checkBoxUpdateLineType">
62
       <property name="text">
63
        <string>Update Line Type</string>
64
       </property>
65
      </widget>
66
     </item>
67
     <item>
61 68
      <spacer name="horizontalSpacer">
62 69
       <property name="orientation">
63 70
        <enum>Qt::Horizontal</enum>

내보내기 Unified diff

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