프로젝트

일반

사용자정보

개정판 ee195020

IDee1950206c2b754291894fb27ad4d286253d108c
상위 7298f494
하위 e2194a0c, d2179741

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

issue #481: apply instrument color

Change-Id: I4f0a257be8b27da189e87eb3c418ceb7ea807093

차이점 보기:

DTI_PID/DTI_PID/AppDocData.py
2573 2573
            cursor.execute(sql)
2574 2574
            rows = cursor.fetchall()
2575 2575
            for row in rows:
2576
                matches = [res for res in result if res['UID']==row[0]]
2576
                matches = [res for res in result if res['UID'] == row[0]]
2577 2577
                if matches:
2578 2578
                    matches[0][row[3]] = row[4]
2579 2579
                else:
2580
                    data = {'UID':row[0], 'ITEM_NO':row[1], 'PNID_NO':row[2]}
2580
                    data = {'UID':row[0], 'ITEM_NO':row[1], 'SIZE':'', 'LINE_NO':'', 'PNID_NO':row[2]}
2581 2581
                    data[row[3]] = row[4]
2582 2582
                    result.append(data)
2583 2583

  
DTI_PID/DTI_PID/ConfigurationDialog.py
12 12
from AppDocData import AppDocData
13 13
from AppDocData import Config
14 14
from AppDocData import Color
15
from EngineeringAbstractItem import QEngineeringAbstractItem
15 16
import Configuration_UI
16 17
import tesseract_ocr_module as TOCR
17 18

  
......
196 197
        self.ui.tableWidgetLineTypes.horizontalHeaderItem(0).setSizeHint(QSize(30, 30))
197 198
        self.ui.tableWidgetLineTypes.setColumnWidth(2, 135)
198 199

  
200
        configs = docData.getConfigs('Instrument', 'Color')
201
        self.ui.pushButtonInstrumentColor.setStyleSheet('background-color:{}'.format(configs[0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR))
199 202
        configs = docData.getConfigs('Symbol Style', 'Opacity')
200 203
        self.ui.spinBoxSymbolOpacity.setValue(int(configs[0].value) if configs else 50)
201 204

  
......
251 254
        self.ui.pushButtonAddProperty.clicked.connect(self.addLineProperty)
252 255
        self.ui.pushButtonDeleteProperty.clicked.connect(self.removeSelectedItem)
253 256
        self.ui.radioButtonFixedSize.toggled.connect(self.onFixedSizeToggled)
257
        self.ui.pushButtonInstrumentColor.clicked.connect(self.change_instrument_color)
254 258
        self.ui.tableWidgetLineTypes.cellDoubleClicked.connect(self.change_line_type_color)
255 259
        self.ui.tableWidgetColorProperty.cellDoubleClicked.connect(self.cellDoubleClick)
256 260
        self.ui.comboBoxColorOption.currentIndexChanged.connect(self.currentIndexChanged)
......
452 456
            #Table Color Setting
453 457
            self.settingColorCell()
454 458

  
459
    def change_instrument_color(self):
460
        """ change instrument's color """
461
        color = QColorDialog.getColor()
462
        if color.isValid():
463
            item = self.ui.pushButtonInstrumentColor.setStyleSheet('background-color:{}'.format(color.name()))
464

  
455 465
    def change_line_type_color(self, row, column):
456 466
        """ change line type's color """
457 467
        if column == 1:
......
626 636
                configs.append(Config('Line No', 'Delimiter', lineInsideDelimiter))
627 637

  
628 638
            # save symbol opacity - 2019.04.18 added by humkyung
639
            configs.append(Config('Instrument', 'Color', self.ui.pushButtonInstrumentColor.palette().color(QPalette.Background).name()))
629 640
            configs.append(Config('Symbol Style', 'Opacity', str(self.ui.spinBoxSymbolOpacity.value())))
630 641

  
631 642
            font = self.ui.fontComboBox.currentFont()
DTI_PID/DTI_PID/Configuration_UI.py
318 318
        self.formLayout_2.setObjectName("formLayout_2")
319 319
        self.label_2 = QtWidgets.QLabel(self.groupBox_2)
320 320
        self.label_2.setObjectName("label_2")
321
        self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_2)
321
        self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
322 322
        self.spinBoxSymbolOpacity = QtWidgets.QSpinBox(self.groupBox_2)
323 323
        self.spinBoxSymbolOpacity.setProperty("value", 50)
324 324
        self.spinBoxSymbolOpacity.setObjectName("spinBoxSymbolOpacity")
325
        self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.spinBoxSymbolOpacity)
325
        self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.spinBoxSymbolOpacity)
326
        self.label_3 = QtWidgets.QLabel(self.groupBox_2)
327
        self.label_3.setObjectName("label_3")
328
        self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_3)
329
        self.pushButtonInstrumentColor = QtWidgets.QPushButton(self.groupBox_2)
330
        self.pushButtonInstrumentColor.setText("")
331
        self.pushButtonInstrumentColor.setObjectName("pushButtonInstrumentColor")
332
        self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.pushButtonInstrumentColor)
326 333
        self.gridLayout_10.addLayout(self.formLayout_2, 0, 0, 1, 1)
327 334
        self.verticalLayout.addWidget(self.groupBox_2)
328 335
        self.groupBox_5 = QtWidgets.QGroupBox(self.tabDisplayOption)
......
467 474
        self.groupBox_6.setTitle(_translate("ConfigurationDialog", "Line Style"))
468 475
        self.groupBox_2.setTitle(_translate("ConfigurationDialog", "Symbol Style"))
469 476
        self.label_2.setText(_translate("ConfigurationDialog", "Symbol Opacity : "))
477
        self.label_3.setText(_translate("ConfigurationDialog", "Instrument Color : "))
470 478
        self.groupBox_5.setTitle(_translate("ConfigurationDialog", "Text Style"))
471 479
        self.labelFontSize.setText(_translate("ConfigurationDialog", "Font Size : "))
472 480
        self.radioButtonAutoSize.setText(_translate("ConfigurationDialog", "Auto"))
DTI_PID/DTI_PID/ItemDataExportDialog.py
85 85
            self.lineNoTableComboBoxDic[16] = self.insulationPurposeList
86 86

  
87 87
            try:
88
                # save scene data
89
                ##self.saveSceneData()
90
                # setting combobox
91 88
                self.initComboBox()
92
                # setting table
93 89
                self.viewTables.append(self.ui.tableWidgetLineDataList)
94 90
                self.viewTables.append(self.ui.tableWidgetEquipmentDataList)
95 91
                self.viewTables.append(self.ui.tableWidgetValveDataList)
DTI_PID/DTI_PID/MainWindow.py
946 946

  
947 947
        self.dlgConfiguration = QConfigurationDialog(self)
948 948
        self.dlgConfiguration.show()
949
        self.dlgConfiguration.exec_()
949
        if QDialog.Accepted == self.dlgConfiguration.exec_():
950
            QEngineeringLineItem.LINE_TYPE_COLORS.clear()
951
            QEngineeringInstrumentItem.INST_COLOR = None
950 952

  
951 953
    '''
952 954
        @brief  show nominal diameter dialog 
......
1026 1028

  
1027 1029
        DisplayColors.instance().option = DisplayOptions.DisplayByLineNo if value == True else DisplayOptions.DisplayByLineType
1028 1030
        if hasattr(self, 'graphicsView'):
1029
            self.graphicsView.scene.update()
1031
            self.graphicsView.scene.update(self.graphicsView.sceneRect())
1030 1032
            DisplayColors.instance().save_data()
1031 1033

  
1032 1034
    '''
DTI_PID/DTI_PID/Shapes/EngineeringInstrumentItem.py
22 22
    """
23 23
    clicked = pyqtSignal(QGraphicsSvgItem)
24 24
    INST_COLUMN_LIST = None 
25
    INST_COLOR = None
25 26

  
26 27
    '''
27 28
    '''
......
119 120
    def tagSuffix(self, value):
120 121
        self._tagSuffix = value
121 122

  
123
    def getColor(self):
124
        """ return instrument's color 2019.04.24 adde by humkyung """
125
        from AppDocData import AppDocData
126
        from DisplayColors import DisplayColors
127
        from DisplayColors import DisplayOptions
128
        from EngineeringAbstractItem import QEngineeringAbstractItem
129
        from EngineeringLineItem import QEngineeringLineItem
130

  
131
        if DisplayOptions.DisplayByLineType == DisplayColors.instance().option:
132
            if self.hover:
133
                return SymbolSvgItem.HOVER_COLOR
134
            elif not QEngineeringInstrumentItem.INST_COLOR:
135
                app_doc_data = AppDocData.instance()
136
                configs = app_doc_data.getConfigs('Instrument', 'Color')
137
                QEngineeringInstrumentItem.INST_COLOR = configs[0].value if configs else QEngineeringAbstractItem.DEFAULT_COLOR
138

  
139
            return QEngineeringInstrumentItem.INST_COLOR
140
        else:
141
            return SymbolSvgItem.getColor(self)
142

  
122 143
    '''
123 144
        @brief  connect attribute
124 145
        @author humkyung
DTI_PID/DTI_PID/Shapes/EngineeringLineItem.py
28 28
    ARROW_SIZE = 30
29 29
    ZVALUE = 100
30 30
    HIGHLIGHT = '#BC4438'
31
    LINE_TYPE_COLORS = {}
31 32

  
32 33
    '''
33 34
        @history    2018.05.11  Jeongwoo    Make Comments self.setPen()
......
1132 1133
    def deleteLineItemFromScene(self):
1133 1134
        self.scene().removeItem(self)
1134 1135
        
1135
    '''
1136
        @brief  return color
1137
        @author Jeongwoo
1138
        @date   2018.05.11
1139
    '''
1140 1136
    def getColor(self):
1137
        """ return line's color """
1141 1138
        from AppDocData import AppDocData
1142 1139
        from DisplayColors import DisplayColors
1143 1140
        from DisplayColors import DisplayOptions
1141
        from EngineeringAbstractItem import QEngineeringAbstractItem
1144 1142

  
1145 1143
        if DisplayOptions.DisplayByLineType == DisplayColors.instance().option:
1146
            app_doc_data = AppDocData.instance()
1147
            configs = app_doc_data.getConfigs('LineTypes', self.lineType)
1148
            if configs:
1149
                tokens = configs[0].value.split(',')
1150
                return tokens[0] if len(tokens) == 4 else '#0000FF'
1144
            if self.hover:
1145
                return QEngineeringAbstractItem.HOVER_COLOR
1151 1146
            else:
1152
                return '#0000FF'
1147
                if self.lineType in QEngineeringLineItem.LINE_TYPE_COLORS:
1148
                    return QEngineeringLineItem.LINE_TYPE_COLORS[self.lineType]
1149
                else:
1150
                    app_doc_data = AppDocData.instance()
1151
                    configs = app_doc_data.getConfigs('LineTypes', self.lineType)
1152
                    if configs:
1153
                        tokens = configs[0].value.split(',')
1154
                        QEngineeringLineItem.LINE_TYPE_COLORS[self.lineType] = tokens[0] if len(tokens) == 4 else QEngineeringAbstractItem.DEFAULT_COLOR
1155
                        return QEngineeringLineItem.LINE_TYPE_COLORS[self.lineType]
1156
                    else:
1157
                        return QEngineeringAbstractItem.DEFAULT_COLOR
1153 1158
        else:
1154 1159
            return QEngineeringAbstractItem.getColor(self)
1155 1160

  
DTI_PID/DTI_PID/Shapes/EngineeringRunItem.py
118 118
        from SymbolSvgItem import SymbolSvgItem
119 119

  
120 120
        try:
121
            # Line 가로, 세로 기준으로 아이템을 묶음 (라인별로)
122
            isVertical = None
123
            lineType = None
124
            itemLists = []
125
            itemList = []
126
            for index in range(len(self.items)):
127
                last = False
128

  
129
                if type(self.items[index]) is QEngineeringLineItem:
130
                    lineVertical = self.items[index].isVertical()
131
                    # Line의 처음 상태 확인 후 저장
132
                    if isVertical == None:
133
                        itemList.append(self.items[index])
134
                        isVertical = lineVertical
135
                        lineType = self.items[index].lineType
136
                    # 속성 확인 다르면 초기화
137
                    elif lineType is not None and lineType != self.items[index].lineType:
138
                        itemLists.append((itemList, isVertical, lineType))
139
                        itemList = []
140
                        isVertical = lineVertical
141
                        lineType = self.items[index].lineType
142
                        itemList.append(self.items[index])
143
                    # Line이 같은 방향이면 저장
144
                    elif isVertical == lineVertical:
145
                        itemList.append(self.items[index])
146
                    # Line이 다른 방향이면 초기화
147
                    else:
148
                        itemLists.append((itemList, isVertical, lineType))
149
                        itemList = []
150
                        isVertical = lineVertical
151
                        lineType = self.items[index].lineType
152
                        itemList.append(self.items[index])
153
                else:
154
                    itemList.append(self.items[index])
155

  
156
                if index == len(self.items) - 1:
157
                    itemLists.append((itemList, isVertical, lineType))
158

  
159
            # Line 별로 라인을 합친 라인을 저장
160
            mergedLines = []
161
            for list in itemLists:
162
                startPoint = []
163
                endPoint = []
164
                # direction의 0 = 낮은 값 -> 높은 값 (좌표 값 기준)
165
                direction = 0
166
                for line in list[0]:
167
                    # 통합 Line의 시작점과 끝점을 구함
168
                    if type(line) is QEngineeringLineItem:
169
                        pt1 = line.startPoint()
170
                        pt2 = line.endPoint()
171
                        if len(startPoint) == 0:
172
                            # vertical 경우
173
                            if list[1]:
174
                                # startPoint가 더 큼
175
                                if pt1[1] > pt2[1]:
176
                                    direction = 1
177
                                # endPoint가 더 큼
178
                                else:
179
                                    direction = 0
180
                            # horizontal 경우
181
                            else:
182
                                if pt1[0] > pt2[0]:
183
                                    direction = 1
184
                                else:
185
                                    direction = 0
186
                        
187
                        # start가 end로 낮은 값에서 높은 값으로
188
                        if direction == 0:
189
                            if list[1]:
190
                                if len(startPoint) == 0:
191
                                    startPoint = pt1 if pt1[1] < pt2[1] else pt2
192
                                    endPoint = pt1 if pt1[1] > pt2[1] else pt2
193
                                else:
194
                                    startPoint = startPoint if startPoint[1] < pt1[1] else pt1
195
                                    startPoint = startPoint if startPoint[1] < pt2[1] else pt2
196
                                    endPoint = endPoint if endPoint[1] > pt1[1] else pt1
197
                                    endPoint = endPoint if endPoint[1] > pt2[1] else pt2
198
                            else:
199
                                if len(startPoint) == 0:
200
                                    startPoint = pt1 if pt1[0] < pt2[0] else pt2
201
                                    endPoint = pt1 if pt1[0] > pt2[0] else pt2
202
                                else:
203
                                    startPoint = startPoint if startPoint[0] < pt1[0] else pt1
204
                                    startPoint = startPoint if startPoint[0] < pt2[0] else pt2
205
                                    endPoint = endPoint if endPoint[0] > pt1[0] else pt1
206
                                    endPoint = endPoint if endPoint[0] > pt2[0] else pt2
207
                        # start가 end로 높은 값에서 낮은 값으로
208
                        else:
209
                            if list[1]:
210
                                if len(startPoint) == 0:
211
                                    startPoint = pt1 if pt1[1] > pt2[1] else pt2
212
                                    endPoint = pt1 if pt1[1] < pt2[1] else pt2
213
                                else:
214
                                    startPoint = startPoint if startPoint[1] > pt1[1] else pt1
215
                                    startPoint = startPoint if startPoint[1] > pt2[1] else pt2
216
                                    endPoint = endPoint if endPoint[1] < pt1[1] else pt1
217
                                    endPoint = endPoint if endPoint[1] < pt2[1] else pt2
218
                            else:
219
                                if len(startPoint) == 0:
220
                                    startPoint = pt1 if pt1[0] > pt2[0] else pt2
221
                                    endPoint = pt1 if pt1[0] < pt2[0] else pt2
222
                                else:
223
                                    startPoint = startPoint if startPoint[0] > pt1[0] else pt1
224
                                    startPoint = startPoint if startPoint[0] > pt2[0] else pt2
225
                                    endPoint = endPoint if endPoint[0] < pt1[0] else pt1
226
                                    endPoint = endPoint if endPoint[0] < pt2[0] else pt2
227

  
228
                # 통합 Line을 추가
229
                if len(startPoint) == 2 and len(endPoint) == 2:
230
                    allLine = QEngineeringLineItem([startPoint, endPoint])
231
                    allLine.lineType = list[2]
232

  
233
                    for line in list[0]:
234
                        if type(line) is QEngineeringLineItem:
235
                            if startPoint[0] == line.startPoint()[0] and startPoint[1] == line.startPoint()[1]:
236
                                if line.connectors[0].connectedItem is None:
237
                                    allLine.connectors[0].connectedItem = None
238
                                elif issubclass(type(line.connectors[0].connectedItem), SymbolSvgItem):
239
                                    allLine.connectors[0].connectedItem = line.connectors[0].connectedItem
240

  
241
                            elif startPoint[0] == line.endPoint()[0] and startPoint[1] == line.endPoint()[1]:
242
                                if line.connectors[1].connectedItem is None:
243
                                    allLine.connectors[0].connectedItem = None
244
                                elif issubclass(type(line.connectors[1].connectedItem), SymbolSvgItem):
245
                                    allLine.connectors[0].connectedItem = line.connectors[1].connectedItem
246
                                
247
                            elif endPoint[0] == line.startPoint()[0] and endPoint[1] == line.startPoint()[1]:
248
                                if line.connectors[0].connectedItem is None:
249
                                    allLine.connectors[1].connectedItem = None
250
                                elif issubclass(type(line.connectors[0].connectedItem), SymbolSvgItem):
251
                                    allLine.connectors[1].connectedItem = line.connectors[0].connectedItem
252

  
253
                            elif endPoint[0] == line.endPoint()[0] and endPoint[1] == line.endPoint()[1]:
254
                                if line.connectors[1].connectedItem is None:
255
                                    allLine.connectors[1].connectedItem = None
256
                                elif issubclass(type(line.connectors[1].connectedItem), SymbolSvgItem):
257
                                    allLine.connectors[1].connectedItem = line.connectors[1].connectedItem
258
                    allLine.uid = '-'
259
                    mergedLines.append(allLine)
260

  
261 121
            node = Element('RUN')
262
            # append merged Line 
263
            mergeNode = Element('MERGEDLINE')
264
            for line in mergedLines:
265
                mergeNode.append(line.toXml())
266
            node.append(mergeNode)
267

  
268 122
            for item in self.items:
269 123
                # skip line item which's connected items are same
270 124
                if (type(item) is QEngineeringLineItem) and (item.connectors[0].connectedItem is item.connectors[1].connectedItem):
......
273 127

  
274 128
                node.append(item.toXml())
275 129

  
276

  
277

  
278 130
        except Exception as ex: 
279
            print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
131
            from App import App 
132
            from AppDocData import MessageType
133

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

  
281 137
        return node
DTI_PID/DTI_PID/Shapes/SymbolSvgItem.py
236 236
        @history    2018.05.09  Jeongwoo    Clear self.connectors
237 237
                    2018.05.30  Jeongwoo    Add parameters (parentSymbol, childSymbol)
238 238
    '''
239
    def buildItem(self, name, type, angle, loc, size, origin, connPts, parentSymbol, childSymbol, hasInstrumentLabel):
239
    def buildItem(self, name, _type, angle, loc, size, origin, connPts, parentSymbol, childSymbol, hasInstrumentLabel):
240 240
        try:
241 241
            docData = AppDocData.instance()
242 242
            self.name = name
243
            self.type = type
243
            self.type = _type
244 244
            self.angle = angle
245 245
            self.loc = loc
246 246
            self.size = size
......
288 288
            self.hasInstrumentLabel = hasInstrumentLabel
289 289
            self.currentPointModeIndex = 0
290 290

  
291
            self.setToolTip(self.name)
291
            self.setToolTip('{} = {}'.format(type(self), self.name))
292 292
        except Exception as ex:
293 293
            from App import App 
294 294

  
DTI_PID/DTI_PID/TextItemFactory.py
111 111
                    pass
112 112
                elif self.isSizeText(text, sizeDelimiter):
113 113
                    item = QEngineeringSizeTextItem()
114
                    item.setToolTip(text)
114
                    item.setToolTip('SIZE = {}'.format(text))
115 115
                    item.setPlainText(text)
116 116
                elif self.isTagNoText(text):
117 117
                    item = QEngineeringTagNoTextItem()
118
                    item.setToolTip(text)
118
                    item.setToolTip('TAG NO = {}'.format(text))
119 119
                    item.setPlainText(text)
120 120
                elif self.is_valve_operation_code(text):
121 121
                    item = QEngineeringValveOperCodeTextItem()
......
170 170
        else:
171 171
            return (False,)
172 172

  
173

  
174 173
    '''
175 174
        @brief      Check Number
176 175
        @author     kyouho
DTI_PID/DTI_PID/UI/Configuration.ui
673 673
           <layout class="QGridLayout" name="gridLayout_10">
674 674
            <item row="0" column="0">
675 675
             <layout class="QFormLayout" name="formLayout_2">
676
              <item row="0" column="0">
676
              <item row="1" column="0">
677 677
               <widget class="QLabel" name="label_2">
678 678
                <property name="text">
679 679
                 <string>Symbol Opacity : </string>
680 680
                </property>
681 681
               </widget>
682 682
              </item>
683
              <item row="0" column="1">
683
              <item row="1" column="1">
684 684
               <widget class="QSpinBox" name="spinBoxSymbolOpacity">
685 685
                <property name="value">
686 686
                 <number>50</number>
687 687
                </property>
688 688
               </widget>
689 689
              </item>
690
              <item row="0" column="0">
691
               <widget class="QLabel" name="label_3">
692
                <property name="text">
693
                 <string>Instrument Color : </string>
694
                </property>
695
               </widget>
696
              </item>
697
              <item row="0" column="1">
698
               <widget class="QPushButton" name="pushButtonInstrumentColor">
699
                <property name="text">
700
                 <string/>
701
                </property>
702
               </widget>
703
              </item>
690 704
             </layout>
691 705
            </item>
692 706
           </layout>

내보내기 Unified diff

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