프로젝트

일반

사용자정보

개정판 8a40f6ee

ID8a40f6ee8685f9e687c399f7e8753b26d35ab4e8
상위 1eed6634
하위 e618acaf

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

issue #1052: 스트림 라인 태그 배치 기능 업데이트

Change-Id: I70d5b49e42e0e656af588810dc16e5124b906a6c

차이점 보기:

HYTOS/HYTOS/MainWindow.py
2376 2376

  
2377 2377
                QApplication.processEvents()
2378 2378

  
2379
            self.rebuild_label()
2380

  
2379 2381
            # """ update scene """
2380 2382
            self.graphicsView.scene.update(self.graphicsView.sceneRect())
2381 2383
            for item in self.graphicsView.scene.items():
HYTOS/HYTOS/Shapes/EngineeringAbstractItem.py
4 4
'''
5 5
    @history    2018.05.15  Jeongwoo    Remove Parent Object [QObject]
6 6
'''
7

  
8

  
7 9
class QEngineeringAbstractItem:
8 10
    '''
9 11
        @history    2018.05.15  Jeongwoo    Remove call super
10 12
                    2018.05.17  Jeongwoo    Add DEFAULT_COLOR Variable
11 13
    '''
12 14
    DEFAULT_COLOR = '#0000FF'
13
    HOVER_COLOR   = '#BC4438'
15
    HOVER_COLOR = '#BC4438'
14 16

  
15 17
    CONNECTED_AT_PT = 0
16 18
    CONNECTED_AT_BODY = 1
......
24 26
        self._area = None
25 27
        self.connectors = []
26 28
        self.attrs = {}  # attributes
27
        self._associations = {'Text Item':[], 'Symbol Item':[]} # associated items
28
    
29
        self._associations = {'Text Item': [], 'Symbol Item': []}  # associated items
30

  
29 31
    @property
30 32
    def hover(self):
31 33
        """ return hover """
......
48 50
        @author     Jeongwoo
49 51
        @date       2018.05.11
50 52
    '''
53

  
51 54
    def setColor(self, color):
52 55
        raise NotImplementedError
53 56

  
......
56 59
        @author Jeongwoo
57 60
        @date   2018.05.11
58 61
    '''
62

  
59 63
    def getColor(self):
60
        return QEngineeringAbstractItem.HOVER_COLOR if self.hover else (self.owner.getColor() if (self.owner and hasattr(self.owner, '_color')) else self._color)
64
        return QEngineeringAbstractItem.HOVER_COLOR if self.hover else (
65
            self.owner.getColor() if (self.owner and hasattr(self.owner, '_color')) else self._color)
61 66

  
62 67
    '''
63 68
        @brief  getter of owner
64 69
        @author humkyung
65 70
        @date   2018.05.12
66 71
    '''
72

  
67 73
    @property
68 74
    def owner(self):
69
        return self._owner 
75
        return self._owner
70 76

  
71 77
    '''
72 78
        @brief  setter of owner
73 79
        @author humkyung
74 80
        @date   2018.05.12
75 81
    '''
82

  
76 83
    @owner.setter
77 84
    def owner(self, value):
78 85
        self._owner = value
......
82 89
        """ check this is connected to other """
83 90
        for connector in self.connectors:
84 91
            if connector.connectedItem: return True
85
        
92

  
86 93
        return False
87 94

  
88 95
    def validate(self):
......
94 101
        @author humkyung
95 102
        @date   2018.09.06
96 103
    '''
104

  
97 105
    @property
98 106
    def area(self):
99 107
        return self._area if self._area is not None else 'None'
......
103 111
        @author humkyung
104 112
        @date   2018.09.06
105 113
    '''
114

  
106 115
    @area.setter
107 116
    def area(self, value):
108 117
        self._area = value
......
112 121
        @author humkyung
113 122
        @date   2018.05.16
114 123
    '''
124

  
115 125
    def toXml(self):
116 126
        pass
117 127

  
......
120 130
        @author humkyung
121 131
        @date   2018.05.16
122 132
    '''
133

  
123 134
    def toXmlAsAttribute(self, parent):
124 135
        pass
125 136

  
......
144 155
                if assoc and type(assoc) is uuid.UUID:
145 156
                    matches = [x for x in self.scene().items() if hasattr(x, 'uid') and str(x.uid) == str(assoc)]
146 157
                    if matches:
147
                        res.append(matches[0]) # TODO: need to update association with instance
158
                        res.append(matches[0])  # TODO: need to update association with instance
148 159
                        self._associations[key][index] = matches[0]
149 160
                    index += 1
150 161
                # up to here
......
188 199
                res.append(symbol)
189 200

  
190 201
        return res
191
    
202

  
192 203
    def getAttributes(self):
193 204
        _attrs = {}
194 205
        try:
......
199 210

  
200 211
            """ get attributes of item from database """
201 212
            docData = AppDocData.instance()
202
            symbolAttrs = docData.getSymbolAttribute(self.type) if type(self) is not QEngineeringLineItem else docData.getSymbolAttribute('Line')
213
            symbolAttrs = docData.getSymbolAttribute(self.type) if type(
214
                self) is not QEngineeringLineItem else docData.getSymbolAttribute('Line')
203 215
            targetAttrs = []
204 216
            if type(self) is not QEngineeringLineItem:
205 217
                for attr in symbolAttrs:
206
                    if attr.Target is None or attr.Target == 'ALL' or [target for target in attr.Target.split(',') if self.dbUid is int(target)]:
218
                    if attr.Target is None or attr.Target == 'ALL' or [target for target in attr.Target.split(',') if
219
                                                                       self.dbUid is int(target)]:
207 220
                        targetAttrs.append(attr)
208 221

  
209 222
            _texts = self.texts()
210 223
            _symbols = self.symbols()
211 224
            for attr in targetAttrs:
212
                matches = [_attr for _attr,_ in self.attrs.items() if _attr.UID == attr.UID]
225
                matches = [_attr for _attr, _ in self.attrs.items() if _attr.UID == attr.UID]
213 226
                if matches:
214
                    attr.Freeze = matches[0].Freeze         ### update freeze value
227
                    attr.Freeze = matches[0].Freeze  ### update freeze value
215 228
                    attr.AssocItem = matches[0].AssocItem
216
                    _attrs[attr] = self.attrs[matches[0]]   ### copy attribute value
229
                    _attrs[attr] = self.attrs[matches[0]]  ### copy attribute value
217 230
                else:
218 231
                    _attrs[attr] = ''
219
 
220
                if attr.Freeze: continue    ### do not evalulate value if attribute is frozen
232

  
233
                if attr.Freeze: continue  ### do not evalulate value if attribute is frozen
221 234
                if attr.AttributeType == 'Text Item' or attr.AttributeType == 'Valve Oper Code':
222 235
                    at = int(attr.AttrAt)
223 236
                    items = [text for text in _texts if QEngineeringAbstractItem.assoc_type(text) == attr.AttributeType]
......
239 252
                        _attrs[attr] = eval(attr.Expression) if attr.Expression else ''
240 253
                    else:
241 254
                        item = attr.AssocItem
242
                        _attrs[attr] = eval(attr.Expression) if attr.Expression and ((item and 'item' in attr.Expression) or 'self' in attr.Expression) else ''
255
                        _attrs[attr] = eval(attr.Expression) if attr.Expression and (
256
                                    (item and 'item' in attr.Expression) or 'self' in attr.Expression) else ''
243 257
                elif attr.AttributeType == 'Symbol Item':
244 258
                    at = int(attr.AttrAt)
245 259
                    if not attr.AssocItem and len(_symbols) > at:
......
252 266
                    else:
253 267
                        _attrs[attr] = ''
254 268

  
255
            for _attr,_value in _attrs.items():
269
            for _attr, _value in _attrs.items():
256 270
                if _value is None or _value == '':
257 271
                    _attr.AssocItem = None
258 272

  
259
            self.attrs = _attrs ### assign self.attrs
273
            self.attrs = _attrs  ### assign self.attrs
260 274
        except Exception as ex:
261
            from App import App 
275
            from App import App
262 276
            from AppDocData import MessageType
263 277

  
264
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
278
            message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
279
                                                           sys.exc_info()[-1].tb_lineno)
265 280
            App.mainWnd().addMessage.emit(MessageType.Error, message)
266
        
281

  
267 282
        return self.attrs
268 283

  
269 284
    def attrib(self, name):
270 285
        """ return the value of given attribute with name """
271
        matches = [(attr,value) for attr,value in self.getAttributes().items() if attr.Attribute == name]
286
        matches = [(attr, value) for attr, value in self.getAttributes().items() if attr.Attribute == name]
272 287
        if matches: return matches[0][1]
273 288

  
274 289
        return None
275 290

  
276 291
    def set_attrib(self, attrib, value):
277 292
        """ set attribute with given value """
278
        matches = [attr for attr,_ in self.attrs.items() if attr.UID == attrib.UID]
293
        matches = [attr for attr, _ in self.attrs.items() if attr.UID == attrib.UID]
279 294
        if len(matches) == 1: self.attrs[matches[0]] = value
280 295

  
281 296
    @staticmethod
282 297
    def assoc_type(item):
283 298
        """ return association type of given item """
284 299
        from EngineeringTextItem import QEngineeringTextItem
285
        from SymbolSvgItem import SymbolSvgItem        
300
        from SymbolSvgItem import SymbolSvgItem
286 301
        from QEngineeringSizeTextItem import QEngineeringSizeTextItem
287 302
        from QEngineeringTagNoTextItem import QEngineeringTagNoTextItem
288 303

  
......
313 328
                    break
314 329
            if freeze:
315 330
                pass
316
                #for assoc in self.associations():
331
                # for assoc in self.associations():
317 332
                #    assoc.owner = self
318 333

  
319 334
            else:
......
324 339
        """ add given item to association """
325 340

  
326 341
        from EngineeringTextItem import QEngineeringTextItem
327
        from SymbolSvgItem import SymbolSvgItem        
342
        from SymbolSvgItem import SymbolSvgItem
328 343
        from QEngineeringSizeTextItem import QEngineeringSizeTextItem
329 344

  
330 345
        for key in self.attrs.keys():
......
335 350
        if _type is not None:
336 351
            if not _type in self._associations:
337 352
                self._associations[_type] = []
338
            
353

  
339 354
            if item in self._associations[_type]: return True
340 355

  
341 356
            if at is None:
342 357
                self._associations[_type].append(item)
343 358
            else:
344 359
                while len(self._associations[_type]) <= at: self._associations[_type].append(None)
345
                #if len(self._associations[_type]) > at and self._associations[_type][at] is not None:
360
                # if len(self._associations[_type]) > at and self._associations[_type][at] is not None:
346 361
                #    self._associations[_type][at].owner = None
347 362
                self._associations[_type][at] = item
348 363

  
HYTOS/HYTOS/Shapes/EngineeringConnectorItem.py
15 15
    except ImportError:
16 16
        raise ImportError("ImageViewerQt: Requires PyQt5 or PyQt4.")
17 17

  
18
from AppDocData import *
18 19
from EngineeringAbstractItem import QEngineeringAbstractItem
19 20

  
20 21

  
......
66 67
    AXIS_MODE = 0
67 68
    FREE_MODE = 1
68 69

  
69
    '''
70
        @brief  
71
        @author 
72
        @date   
73
        @history        humkyung 2018.07.27 add member for connectedItem
74
                        humkyung 2018.09.03 remove code to add connector item
75
    '''
76

  
77 70
    def __init__(self, uid=None, parent=None, index=-1):
71
        """constructor of connector"""
78 72
        import uuid
79 73
        from SymbolSvgItem import SymbolSvgItem
74
        from EngineeringEqpDescTextItem import QEngineeringEqpDescTextItem
80 75

  
81 76
        QGraphicsEllipseItem.__init__(self, parent)
82 77

  
......
220 215
            elif self.connectedItem and parent.name in ['CV_H', 'CV_V']:
221 216
                if self.data is None or self.data.elevation is None:
222 217
                    res.extend([self, 'need to check elevation'])
223
            elif parent.name == 'Line Splitter':    # set default value for line splitter
218
            elif parent.name == 'Line Splitter':  # set default value for line splitter
224 219
                if self.connectedItem:
225 220
                    if self.data.pressure_drop is None:
226 221
                        self.data.pressure_drop = 0
......
233 228
        if self.connectedItem and type(self.parentItem()) is SymbolSvgItem:
234 229
            self.setBrush(Qt.red) if res else self.setBrush(Qt.yellow)
235 230
        else:
236
            self.setBrush(Qt.blue)
231
            self.setBrush(Qt.yellow) if self.connectedItem else self.setBrush(Qt.blue)
237 232
        # up to here
238 233

  
239 234
        return res
240 235

  
241
    '''
242
        @brief      return direction vector
243
        @author     humkyung
244
        @date       2018.09.01
245
    '''
246

  
247 236
    def dir(self):
237
        """return direction vector"""
248 238
        if self._direction == 'LEFT':
249
            return (-1, 0)
239
            return -1, 0
250 240
        elif self._direction == 'RIGHT':
251
            return (1, 0)
241
            return 1, 0
252 242
        elif self._direction == 'UP':
253
            return (0, -1)
243
            return 0, -1
254 244
        elif self._direction == 'DOWN':
255
            return (0, 1)
245
            return 0, 1
256 246

  
257 247
        return None
258 248

  
......
337 327
            c = QColor()
338 328
            c.setNamedColor(QEngineeringConnectorItem.HIGHLIGHT)
339 329
            self.setPen(Qt.red)
340
            #self.setBrush(c)
330
            # self.setBrush(c)
341 331
            if hasattr(self, '_label'):
342 332
                font = self._label.font()
343 333
                font.setBold(True)
......
347 337
            self.setRect(self._loc[0] - round(self.SMALL_SIZE * 0.5), self._loc[1] - round(self.SMALL_SIZE * 0.5),
348 338
                         self.SMALL_SIZE, self.SMALL_SIZE)
349 339
            self.setPen(Qt.black)
350
            #self.setBrush(Qt.yellow) if self.connectedItem else self.setBrush(Qt.blue)
340
            # self.setBrush(Qt.yellow) if self.connectedItem else self.setBrush(Qt.blue)
351 341
            if hasattr(self, '_label'):
352 342
                font = self._label.font()
353 343
                font.setBold(False)
HYTOS/HYTOS/Shapes/EngineeringEqpDescTextItem.py
4 4
import os.path
5 5
import sys
6 6
import copy
7

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

  
20

  
18 21
class QEngineeringEqpDescTextItem(QGraphicsTextItem):
19 22
    """ This is engineering equipment description text item class """
20 23

  
......
38 41

  
39 42
    def set_font_color(self, color):
40 43
        self.setDefaultTextColor(QColor(color))
41

  
HYTOS/HYTOS/Shapes/EngineeringStreamNoTextItem.py
4 4
import os.path
5 5
import sys
6 6
import copy
7

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

  
18
from AppDocData import AppDocData,MessageType
20
from AppDocData import AppDocData, MessageType
21
from EngineeringAbstractItem import QEngineeringAbstractItem
22

  
19 23

  
20 24
class QEngineeringStreamNoTextItem(QGraphicsTextItem):
21 25
    """ This is engineering stream no text item class """
......
34 38
        font.setPointSizeF(4)
35 39
        self.setFont(font)
36 40

  
41
    def highlight(self, flag):
42
        if flag:
43
            self.setDefaultTextColor(QColor(QEngineeringAbstractItem.HOVER_COLOR))
44
        else:
45
            self.setDefaultTextColor(Qt.black)
46

  
47
        self.update()
48

  
37 49
    def paint(self, painter, option, widget):
38 50
        """ override paint method """
39 51

  
40
        painter.setPen(QPen(Qt.black, 1))
41 52
        painter.drawPolygon(self.create_poly(4, 7, 0))
42 53
        QGraphicsTextItem.paint(self, painter, option, widget)
43 54

  
......
51 62
            t = w * i + s
52 63
            x = r * math.cos(math.radians(t))
53 64
            y = r * math.sin(math.radians(t))
54
            polygon.append(QPointF(rect.width()*0.5 + x, rect.height()*0.5 + y))
65
            polygon.append(QPointF(rect.width() * 0.5 + x, rect.height() * 0.5 + y))
55 66

  
56 67
        return polygon
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py
681 681
                option.setAlignment(Qt.AlignCenter)
682 682
                doc.setDefaultTextOption(option)
683 683
                if max_length_line[0] is not None and max_length_line[1] is not None:
684
                    padding = 2
685

  
684 686
                    self._stream_no_text.setTextWidth(doc.idealWidth())
685 687
                    dx = max_length_line[0][0] - max_length_line[1][0]
686 688
                    dy = max_length_line[0][1] - max_length_line[1][1]
687
                    if abs(dx) >= abs(dy):
689
                    if abs(dx) >= abs(dy):  # horizontal line
690
                        rect = self._stream_no_text.boundingRect()
688 691
                        x = (max_length_line[0][0] + max_length_line[1][0] - self._stream_no_text.textWidth()) * 0.5
689
                        y = (max_length_line[0][1] + max_length_line[1][1]) * 0.5
692
                        y = (max_length_line[0][1] + max_length_line[1][1]) * 0.5 - rect.height() - padding
690 693
                        self._stream_no_text.setPos(QPointF(x, y))
691
                    else:
692
                        x = (max_length_line[0][0] + max_length_line[1][0]) * 0.5
694
                    else:   # vertical line
695
                        x = (max_length_line[0][0] + max_length_line[1][0]) * 0.5 + padding
693 696
                        y = (max_length_line[0][1] + max_length_line[1][1] - self._stream_no_text.textWidth()) * 0.5
694 697
                        self._stream_no_text.setPos(QPointF(x, y))
695 698

  
......
785 788
        self.highlight(False)
786 789

  
787 790
    def highlight(self, flag):
791
        from EngineeringStreamNoTextItem import QEngineeringStreamNoTextItem
792

  
788 793
        self.hover = flag
789 794
        self.setZValue(QEngineeringAbstractItem.HOVER_ZVALUE) if flag else \
790 795
            self.setZValue(QEngineeringStreamlineItem.ZVALUE)
796

  
797
        self._stream_no_text.highlight(flag)
791 798
        self.update()
792 799

  
793 800
    def paint(self, painter, option, widget):
HYTOS/HYTOS/Shapes/SymbolSvgItem.py
121 121
            App.mainWnd().addMessage.emit(MessageType.Error, message)
122 122

  
123 123
        self.setZValue(SymbolSvgItem.ZVALUE)
124
        self._desc_label = QEngineeringEqpDescTextItem('eqp name<br>pressure drop<br>elevation', self)
124
        self.desc_labels = []
125 125

  
126 126
    def has_attribute(self):
127 127
        if len(self.attribute) > 0:
......
206 206

  
207 207
        return None
208 208

  
209
    @property
210
    def desc_label(self):
211
        """ return equipment description label """
212

  
213
        return self._desc_label
214

  
215 209
    def validate(self):
216 210
        """validate symbol data"""
217 211

  
......
368 362
                                                           sys.exc_info()[-1].tb_lineno)
369 363
            App.mainWnd().addMessage.emit(MessageType.Error, message)
370 364

  
365
    def get_label_pos_of_connector(self, conn, label):
366
        """return label position of given connector"""
367

  
368
        res = None
369

  
370
        label_rect = label.boundingRect()
371
        conn_rect = conn.mapRectFromParent(conn.boundingRect())
372
        dx, dy = conn.dir()
373

  
374
        if dx == 1:
375
            res = QPointF(conn_rect.x() + conn_rect.width() * 0.5, conn_rect.y())
376
        elif dy == -1:
377
            res = QPointF(conn_rect.x() + conn_rect.width()*0.5, conn_rect.y() - label_rect.height())
378
        elif dy == 1:
379
            res = QPointF(conn_rect.x() + conn_rect.width()*0.5, conn_rect.y() + conn_rect.height()*0.5)
380
        elif dx == -1:
381
            res = QPointF(conn_rect.x() - label_rect.width() - conn_rect.width()*0.5,
382
                          conn_rect.y() + conn_rect.height()*0.5)
383

  
384
        return res
385

  
371 386
    def build_label(self):
372
        """ build equipment label """
387
        """build equipment label"""
373 388

  
374 389
        rect = self.boundingRect()
375 390

  
376 391
        app_doc_data = AppDocData.instance()
377 392
        units = [attr[1] for attr in app_doc_data.activeDrawing.attrs if attr[0] == 'Units'][0]
378 393

  
394
        # clear labels
395
        for label in self.desc_labels:
396
            label.setHtml('')
397

  
379 398
        if self.category == 'Equipment - [ Pressure Drop ]':
380 399
            if self.type == 'Air Fin Cooler':
381
                if self.tag_no:
382
                    data = self.connectors[0].data
383
                    if data:
384
                        self.desc_label.setHtml(
385
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
386
                else:
387
                    self.desc_label.setHtml('')
400
                index = 0
401
                for conn in self.connectors:
402
                    if self.tag_no:
403
                        if conn.data:
404
                            conn_rect = conn.boundingRect()
405
                            self.desc_labels[index].setHtml(
406
                                f"{self.tag_no}<br>{convert_to_fixed_point(conn.data.pressure_drop)} {units['Pressure']}<br>"
407
                                f"{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
408
                            self.desc_labels[index].setPos(QPointF(conn_rect.width(), 0))
409
                    index += 1
388 410
            elif self.type == 'Filter':
389 411
                if self.tag_no:
390
                    data = self.connectors[0].data
391
                    if data:
392
                        self.desc_label.setHtml(
393
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
394
                else:
395
                    self.desc_label.setHtml('')
412
                    index = 0
413
                    for conn in self.connectors:
414
                        if conn.data:
415
                            conn_rect = conn.boundingRect()
416
                            self.desc_labels[index].setHtml(
417
                                f"{self.tag_no}<br>{convert_to_fixed_point(conn.data.pressure_drop)} {units['Pressure']}<br>"
418
                                f"{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
419
                            self.desc_labels[index].setPos(QPointF(conn_rect.width(), 0))
420
                        index += 1
396 421
            elif self.type == 'Heat Exchanger':
397 422
                if self.tag_no:
398
                    data = [conn.data for conn in self.connectors
399
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
400
                    if data:
401
                        self.desc_label.setHtml(
402
                            f"{self.tag_no}<br>{convert_to_fixed_point(data[0].pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data[0].elevation)} {units['Length']}")
403
                else:
404
                    self.desc_label.setHtml('')
423
                    conns = [conn for conn in self.connectors
424
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
425
                    if conns:
426
                        self.desc_labels[0].setHtml(
427
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} {units['Pressure']}<br>"
428
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
429
                        pos = self.get_label_pos_of_connector(conns[0], self.desc_labels[0])
430
                        self.desc_labels[0].setPos(pos)
405 431
            elif self.type == 'Miscellaneous':
406 432
                if self.name == 'M_Coil':
407 433
                    if self.tag_no:
408
                        data = self.connectors[0].data
409
                        if data:
410
                            self.desc_label.setHtml(
411
                                f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
412
                    else:
413
                        self.desc_label.setHtml('')
434
                        index = 0
435
                        for conn in self.connectors:
436
                            if conn.data:
437
                                conn_rect = conn.boundingRect()
438
                                self.desc_labels[index].setHtml(
439
                                    f"{self.tag_no}<br>{convert_to_fixed_point(conn.data.pressure_drop)} {units['Pressure']}<br>"
440
                                    f"{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
441
                                self.desc_labels[index].setPos(QPointF(conn_rect.width(), 0))
442

  
443
                            index += 1
414 444
                elif self.name in ('M_DP_E', 'M_React'):
415 445
                    if self.tag_no:
416
                        data = [conn.data for conn in self.connectors
417
                                if
418
                                conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
419
                        if data:
420
                            self.desc_label.setHtml(
421
                                f"{self.tag_no}<br>{convert_to_fixed_point(data[0].pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data[0].elevation)} {units['Length']}")
422
                    else:
423
                        self.desc_label.setHtml('')
446
                        conns = [conn for conn in self.connectors
447
                                if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
448
                        if conns:
449
                            self.desc_labels[0].setHtml(
450
                                f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} {units['Pressure']}"
451
                                f"<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
452
                            label_rect = self.desc_labels[0].boundingRect()
453
                            self.desc_labels[0].setPos(
454
                                QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
424 455
            elif self.type == 'Strainer':
425 456
                if self.tag_no:
426
                    data = self.connectors[0].data
427
                    if data:
428
                        self.desc_label.setHtml(
429
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
430
                else:
431
                    self.desc_label.setHtml('')
457
                    conns = [conn for conn in self.connectors
458
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
459
                    if conns:
460
                        self.desc_labels[0].setHtml(
461
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} {units['Pressure']}<br>"
462
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
463

  
464
                        label_rect = self.desc_labels[0].boundingRect()
465
                        self.desc_labels[0].setPos(
466
                            QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
432 467
        elif self.category == 'Equipment - [ Pressurized ]':
433 468
            if self.type == 'Battery Limit':
434
                if self.tag_no:
435
                    data = [conn.data for conn in self.connectors
436
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
437
                    if data:
438
                        self.desc_label.setHtml(
439
                            f"{self.tag_no}<br>{convert_to_fixed_point(data[0].pressure)} {units['Pressure']}(g)<br>{convert_to_fixed_point(data[0].elevation)} {units['Length']}")
440
                else:
441
                    self.desc_label.setHtml('')
469
                if self.tag_no and self.connectors[0].data:
470
                    index = 0
471
                    data = self.connectors[0].data
472
                    if data and (data.pressure_drop is not None or data.elevation is not None):
473
                        self.desc_labels[0].setHtml(
474
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure)} {units['Pressure']}(g)<br>"
475
                            f"{convert_to_fixed_point(data.elevation)} {units['Length']}")
476
                        label_rect = self.desc_labels[0].boundingRect()
477
                        self.desc_labels[0].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
442 478
            elif self.type == 'Column':
443 479
                if self.tag_no:
444
                    conn = [conn for conn in self.connectors
445
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
446
                    if conn:
447
                        data = conn[0].data
448
                        nozzle = str(conn[0]).rsplit('_', 1)[1]
449
                        if data:
450
                            self.desc_label.setHtml(
451
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(data.pressure)} {units['Pressure']}(g)<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
452
                else:
453
                    self.desc_label.setHtml('')
480
                    index = 0
481
                    for conn in self.connectors:
482
                        if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None):
483
                            nozzle = str(conn).rsplit('_', 1)[1]
484
                            self.desc_labels[index].setHtml(
485
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(conn.data.pressure)} "
486
                                f"{units['Pressure']}(g)<br>{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
487
                            pos = self.get_label_pos_of_connector(conn, self.desc_labels[index])
488
                            self.desc_labels[index].setPos(pos)
489

  
490
                        index += 1
454 491
            elif self.type == 'Drum':
455 492
                if self.tag_no:
456
                    conn = [conn for conn in self.connectors
457
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
458
                    if conn:
459
                        data = conn[0].data
460
                        nozzle = str(conn[0]).rsplit('_', 1)[1]
461
                        if data:
462
                            self.desc_label.setHtml(
463
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(data.pressure)} {units['Pressure']}(g)<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
464
                else:
465
                    self.desc_label.setHtml('')
493
                    index = 0
494
                    for conn in self.connectors:
495
                        if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None):
496
                            nozzle = str(conn).rsplit('_', 1)[1]
497
                            self.desc_labels[index].setHtml(
498
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(conn.data.pressure)} "
499
                                f"{units['Pressure']}(g)<br>{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
500

  
501
                            pos = self.get_label_pos_of_connector(conn, self.desc_labels[index])
502
                            self.desc_labels[index].setPos(pos)
503

  
504
                        index += 1
466 505
            elif self.type == 'Miscellaneous':
467 506
                if self.tag_no:
468
                    conn = [conn for conn in self.connectors
469
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
470
                    if conn:
471
                        data = conn[0].data
472
                        nozzle = str(conn[0]).rsplit('_', 1)[1]
473
                        if data:
474
                            self.desc_label.setHtml(
475
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(data.pressure)} {units['Pressure']}(g)<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
476
                else:
477
                    self.desc_label.setHtml('')
507
                    index = 0
508
                    for conn in self.connectors:
509
                        if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None):
510
                            nozzle = str(conn).rsplit('_', 1)[1]
511
                            if conn.data:
512
                                self.desc_labels[index].setHtml(
513
                                    f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(conn.data.pressure)} "
514
                                    f"{units['Pressure']}(g)<br>{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
515

  
516
                        index += 1
478 517
            elif self.type == 'Tank':
479 518
                if self.tag_no:
480
                    conn = [conn for conn in self.connectors
481
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
482
                    if conn:
483
                        data = conn[0].data
484
                        nozzle = str(conn[0]).rsplit('_', 1)[1]
485
                        if data:
486
                            self.desc_label.setHtml(
487
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(data.pressure)} {units['Pressure']}(g)<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
488
                else:
489
                    self.desc_label.setHtml('')
519
                    index = 0
520
                    for conn in self.connectors:
521
                        if conn.data and conn.connectedItem and \
522
                                (conn.data.pressure_drop is not None or conn.data.elevation is not None):
523
                            nozzle = str(conn).rsplit('_', 1)[1]
524
                            self.desc_labels[index].setHtml(
525
                                f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(conn.data.pressure)} "
526
                                f"{units['Pressure']}(g)<br>{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
527

  
528
                            pos = self.get_label_pos_of_connector(conn, self.desc_labels[index])
529
                            self.desc_labels[index].setPos(pos)
530

  
531
                        index += 1
490 532
        elif self.category == 'Equipment - [ Rotating ]':
491 533
            if self.type == 'Compressor':
492 534
                if self.name in ('L_Comp', 'R_Comp'):
493 535
                    if self.tag_no:
494
                        conn = [conn for conn in self.connectors
495
                                if
496
                                conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None)]
497
                        if conn:
498
                            data = conn[0].data
499
                            nozzle = str(conn[0]).rsplit('_', 1)[1]
500
                            if data:
501
                                self.desc_label.setHtml(
502
                                    f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(data.pressure)} {units['Pressure']}(g)<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
503
                    else:
504
                        self.desc_label.setHtml('')
536
                        index = 0
537
                        for conn in self.connectors:
538
                            if conn.data and (conn.data.pressure_drop is not None or conn.data.elevation is not None):
539
                                nozzle = str(conn).rsplit('_', 1)[1]
540
                                self.desc_labels[index].setHtml(
541
                                    f"{self.tag_no}_{nozzle}<br>{convert_to_fixed_point(conn.data.pressure)} "
542
                                    f"{units['Pressure']}(g)<br>{convert_to_fixed_point(conn.data.elevation)} {units['Length']}")
543

  
544
                                pos = self.get_label_pos_of_connector(conn, self.desc_labels[index])
545
                                self.desc_labels[index].setPos(pos)
546

  
547
                            index += 1
505 548
                elif self.name in ('L_Komp', 'R_Komp'):
506 549
                    if self.tag_no:
507 550
                        data = self.connectors[0].data
508 551
                        if data:
509
                            self.desc_label.setHtml(
552
                            self.desc_labels[0].setHtml(
510 553
                                f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop) if data.pressure_drop is not None else 0} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
511
                    else:
512
                        self.desc_label.setHtml('')
513 554
            elif self.type == 'Pump':
514 555
                if self.tag_no:
515
                    data = self.connectors[0].data
516
                    if data:
517
                        self.desc_label.setHtml(
518
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop) if data.pressure_drop is not None else 0} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
519
                else:
520
                    self.desc_label.setHtml('')
556
                    conns = [conn for conn in self.connectors if conn.data and conn.data.elevation is not None]
557
                    if conns:
558
                        self.desc_labels[0].setHtml(
559
                            f"{self.tag_no}<br>"
560
                            f"{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
561
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
562

  
563
                        label_rect = self.desc_labels[0].boundingRect()
564
                        self.desc_labels[0].setPos(
565
                            QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
521 566
        elif self.category == 'Instrument':
522 567
            if self.type == 'Flowmeter':
523 568
                if self.tag_no:
524 569
                    data = self.connectors[0].data
525 570
                    if data:
526
                        self.desc_label.setHtml(
527
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
528
                else:
529
                    self.desc_label.setHtml('')
571
                        self.desc_labels[0].setHtml(
572
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} "
573
                            f"{units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
574

  
575
                        label_rect = self.desc_labels[0].boundingRect()
576
                        self.desc_labels[0].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
530 577
            elif self.type == 'Line Splitter':
531 578
                if self.tag_no:
532
                    data = self.connectors[0].data
533
                    if data:
534
                        self.desc_label.setHtml(
535
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
536
                else:
537
                    self.desc_label.setHtml('')
579
                    conns = [conn for conn in self.connectors
580
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
581
                    if conns:
582
                        self.desc_labels[0].setHtml(
583
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} "
584
                            f"{units['Pressure']}<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
585

  
586
                        label_rect = self.desc_labels[0].boundingRect()
587
                        self.desc_labels[0].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
538 588
            elif self.type == 'Reducer':
539 589
                if self.tag_no:
540
                    data = self.connectors[0].data
541
                    if data:
542
                        self.desc_label.setHtml(
543
                            f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
544
                else:
545
                    self.desc_label.setHtml('')
590
                    conns = [conn for conn in self.connectors
591
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
592
                    if conns:
593
                        self.desc_labels[0].setHtml(
594
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} "
595
                            f"{units['Pressure']}<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
596

  
597
                        label_rect = self.desc_labels[0].boundingRect()
598
                        self.desc_labels[0].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
546 599
            elif self.type == 'Valve':
547
                if self.name in ('CV_H', 'CV_V'):
548
                    if self.tag_no:
549
                        data = self.connectors[0].data
550
                        if data:
551
                            self.desc_label.setHtml(
552
                                f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop) if data.pressure_drop is not None else 0} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
553
                    else:
554
                        self.desc_label.setHtml('')
555
                elif self.name in ('MV_H', 'MV_V'):
556
                    if self.tag_no:
557
                        data = self.connectors[0].data
558
                        if data:
559
                            self.desc_label.setHtml(
560
                                f"{self.tag_no}<br>{convert_to_fixed_point(data.pressure_drop)} {units['Pressure']}<br>{convert_to_fixed_point(data.elevation)} {units['Length']}")
561
                    else:
562
                        self.desc_label.setHtml('')
563
        else:
564
            if self.tag_no:
565
                self.desc_label.setHtml(f"{self.tag_no}")
566
            else:
567
                self.desc_label.setHtml('')
568

  
569
        self.desc_label.setPos(QPointF(rect.width(), 0))
570

  
571
        app_doc_data = AppDocData.instance()
600
                if self.tag_no and self.name in ('CV_H', 'CV_V'):
601
                    conns = [conn for conn in self.connectors
602
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
603
                    if conns:
604
                        self.desc_labels[0].setHtml(
605
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop) if conns[0].data.pressure_drop is not None else 0} {units['Pressure']}<br>"
606
                            f"{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
607

  
608
                        label_rect = self.desc_labels[0].boundingRect()
609
                        self.desc_labels[0].setPos(QPointF((rect.width() - label_rect.width())*0.5, rect.height()))
610
                elif self.tag_no and self.name in ('MV_H', 'MV_V'):
611
                    conns = [conn for conn in self.connectors
612
                             if conn.data and conn.data.pressure_drop is not None and conn.data.elevation is not None]
613
                    if conns:
614
                        self.desc_labels[0].setHtml(
615
                            f"{self.tag_no}<br>{convert_to_fixed_point(conns[0].data.pressure_drop)} "
616
                            f"{units['Pressure']}<br>{convert_to_fixed_point(conns[0].data.elevation)} {units['Length']}")
617

  
618
                        label_rect = self.desc_labels[0].boundingRect()
619
                        self.desc_labels[0].setPos(QPointF((rect.width() - label_rect.width()) * 0.5, rect.height()))
620

  
621
        font_size = None
572 622
        configs = app_doc_data.getAppConfigs('option', 'TagFontSize')
573 623
        if configs and len(configs) == 1:
574
            self.desc_label.set_font_size(configs[0].value)
624
            font_size = configs[0].value
575 625

  
626
        font_color = None
576 627
        configs = app_doc_data.getAppConfigs('option', 'TagFontColor')
577 628
        if configs and len(configs) == 1:
578
            self.desc_label.set_font_color(configs[0].value)
629
            font_color = configs[0].value
579 630

  
580
    '''
581
        @brief  return bounding box of symbol
582
        @author humkyung
583
        @date   2018.04.08
584
    '''
631
        for label in self.desc_labels:
632
            if font_size:  label.set_font_size(font_size)
633
            if font_color:  label.set_font_color(font_color)
585 634

  
586 635
    def rect(self):
636
        """return bounding box of symbol"""
587 637
        return self.sceneBoundingRect()
588 638

  
589 639
    '''
......
1363 1413
        painter.setPen(self.focuspen)
1364 1414
        painter.drawRect(self.boundingRect())
1365 1415

  
1366
    '''
1367
        @brief  override paint(draw connection points)
1368
        @author humkyung
1369
        @date   2018.04.21
1370
    '''
1371

  
1372 1416
    def paint(self, painter, options=None, widget=None):
1417
        """override paint(draw connection points)"""
1373 1418
        from EngineeringAbstractItem import QEngineeringAbstractItem
1374 1419
        from EngineeringTextItem import QEngineeringTextItem
1375 1420

  
......
1417 1462
    def onConnectorPosChaned(self, connector):
1418 1463
        pass
1419 1464

  
1420
    '''
1421
        @brief      set connector
1422
        @author     kyouho
1423
        @date       2018.07.26
1424
    '''
1425

  
1426 1465
    def set_connector(self, uid, index=None):
1466
        """set connector"""
1427 1467
        from AppDocData import AppDocData
1428 1468

  
1429 1469
        app_doc_data = AppDocData.instance()
......
1431 1471
        connector.data = app_doc_data.get_nozzle_data(uid)
1432 1472
        self.connectors.append(connector)
1433 1473

  
1474
        label = QEngineeringEqpDescTextItem('eqp name<br>pressure drop<br>elevation', self)
1475
        self.desc_labels.append(label)
1476

  
1434 1477
    '''
1435 1478
    '''
1436 1479

  
......
1465 1508
        rect.moveTo(self.loc[0], self.loc[1])
1466 1509
        return rect
1467 1510

  
1468
    def flipSymbol(self):
1469
        '''
1470
            @brief  remove item when user press delete key
1471
            @author humkyung
1472
            @date   2018.04.23
1473
        '''
1474
        if self.flip is 0:
1475
            self.flip = 1
1476
        else:
1477
            self.flip = 0
1478

  
1479
        currentPoint = self.getCurrentPoint()
1480
        self.reSettingSymbol(currentPoint, self.angle)
1481

  
1482 1511
    '''
1483 1512
        @brief      rotate Symbol
1484 1513
        @author     kyouho
......
1491 1520
            if 0 == self.angle:
1492 1521
                self.angle = 1.57
1493 1522
            # degree 90
1494
            elif (1.57 == self.angle):
1523
            elif 1.57 == self.angle:
1495 1524
                self.angle = 3.14
1496 1525
            # degree 180
1497 1526
            elif 3.14 == self.angle:

내보내기 Unified diff

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