프로젝트

일반

사용자정보

개정판 e1556005

IDe1556005ae02ad40e4ab16cdedfa5d27486e4593
상위 2819dd5f
하위 47a53a74

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

issue #1052: Streamline 태그 위치 보정

Change-Id: I2a396113b58a00c365075ab0388d4b4fb4bad0fb

차이점 보기:

HYTOS/HYTOS/QtImageViewer.py
572 572
        return svg
573 573
        
574 574
    '''
575
        @brief      match symbol to line
576
        @author     kyouho
577
        @date       2018.07.27
578
        @history    humkyung 2018.08.23 change scenePos to connector's center when symbol is placed on connector
579
    '''
580
    def matchSymbolToLine(self, svg, scenePos):
581
        from EngineeringConnectorItem import QEngineeringConnectorItem
582

  
583
        items = [item for item in self.scene.items(scenePos) if type(item) is not QGraphicsPixmapItem]
584
        if len(items) > 0 and type(items[0]) is QEngineeringConnectorItem:
585
            scenePos = QPointF(items[0].center()[0], items[0].center()[1])
586

  
587
        transform = QTransform()
588
        transform.translate(scenePos.x() - svg.symbolOrigin[0], scenePos.y() - svg.symbolOrigin[1])
589
        svg.setTransform(transform)
590
        svg.loc = [round(scenePos.x() - svg.symbolOrigin[0], 1), round(scenePos.y() - svg.symbolOrigin[1], 1)]
591
        svg.size = [svg.boundingRect().width(), svg.boundingRect().height()]
592
        svg.origin = [round(scenePos.x(), 1), round(scenePos.y(), 1)]
593
        self.scene.addItem(svg)
594

  
595
        svg.transfer.onRemoved.connect(self.mainWindow.on_item_removed)
596

  
597
        for conn in svg.connectors:
598
            conn.sceneConnectPoint = (conn.sceneBoundingRect().center().x(), conn.sceneBoundingRect().center().y())
599

  
600
        self.scene.clearFocus()
601
        for item in self.scene.selectedItems():
602
            item.setSelected(False)
603

  
604
        #self.setFocus()
605
        #svg.setSelected(True)
606
        #self.scene.setFocusItem(svg)
607

  
608
    '''
609 575
        @brief  find item by uid (SymbolSvgItem 기반, QEngineeringConnectorItem 제외, QEngineeringLineItem 포함)
610 576
        @author kyouho
611 577
        @date   2018.07.31
HYTOS/HYTOS/Shapes/EngineeringStreamNoTextItem.py
24 24
        import uuid
25 25

  
26 26
        QGraphicsTextItem.__init__(self, text, parent)
27
        doc = self.document()
28
        option = doc.defaultTextOption()
29
        option.setAlignment(Qt.AlignCenter)
30
        doc.setDefaultTextOption(option)
27 31
        self.type = 'STREAM NO'
28 32

  
29 33
        font = QFont('Arial', 15)
30 34
        font.setPointSizeF(5)
31
        self.setFont(font)
35
        self.setFont(font)
HYTOS/HYTOS/Shapes/EngineeringStreamlineItem.py
159 159
            symbol.transfer.on_pos_changed.connect(self.on_symbol_pos_changed)
160 160
            symbol.transfer.on_size_changed.connect(self.on_symbol_pos_changed)
161 161

  
162
        self.update_arrow()
163

  
164 162
    def update_arrow(self):
165 163
        """ update flow arrow """
166 164
        import math
......
237 235
            return
238 236

  
239 237
        try:
240
            # re-positioning vertex of stream line
241
            self._vertices = []
242

  
243
            self._vertices.append(self.connectors[0].center())
244
            dx = self.connectors[-1].center()[0] - self._vertices[0][0]
245
            dy = self.connectors[-1].center()[1] - self._vertices[0][1]
246
            if (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
247
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
248
                if dx >= 0 and dy > 0:
249
                    self._vertices.append((self._vertices[0][0], self._vertices[0][1] + dy))
250
                elif dx < 0 <= dy:
251
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
252
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
253
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
254
                elif dx < 0 and dy < 0:
255
                    self._vertices.append(
256
                        (self._vertices[0][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
257
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
258
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
259
                elif dx > 0 > dy:
260
                    self._vertices.append(
261
                        (self._vertices[0][0], self._vertices[0][1] + QEngineeringStreamlineItem.MIN_LENGTH))
262
                    self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
263
                    self._vertices.append((self._vertices[-1][0], self.connectors[-1].center()[1]))
264
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
265
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
266
                if dx >= 0 and dy < 0:
267
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
268
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
269
                    self._vertices.append((self._vertices[-1][0],
270
                                           self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
271
                elif dx < 0 and dy < 0:
272
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
273
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
274
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
275
                elif dx < 0 and dy >= 0:
276
                    self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy))
277
                elif dx >= 0 and dy >= 0:
278
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
279
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
280
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
281
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
282
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
283
                if dx >= 0 and dy < 0:
284
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
285
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
286
                    self._vertices.append((self._vertices[-1][0],
287
                                           self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH*2))
288
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
289
                elif dx < 0 and dy < 0:
290
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
291
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
292
                    self._vertices.append((self._vertices[-1][0],
293
                                           self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH * 2))
294
                    self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
295
                elif dx < 0 and dy >= 0:
296
                    self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy*0.5))
297
                    self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
298
                elif dx >= 0 and dy >= 0:
299
                    self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy * 0.5))
300
                    self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
301
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
302
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
303
                if dx >= 0 and dy < 0:
304
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
305
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
306
                elif dx < 0 and dy < 0:
307
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
308
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
309
                elif dx < 0 and dy >= 0:
310
                    self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
311
                    self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
312
                elif dx >= 0 and dy >= 0:
313
                    self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
314
                    self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
315
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
316
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
317
                if dx >= 0 and dy < 0:
318
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
319
                elif dx >= 0 and dy >= 0:
320
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
321
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
322
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
323
                elif dx < 0 and dy >= 0:
324
                    self._vertices.append(
325
                        (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
326
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH , self._vertices[-1][1]))
327
                    self._vertices.append(
328
                        (self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
329
                else:
330
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
331
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
332
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
333
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
334
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
335
                if dx >= 0 and dy < 0:
336
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
337
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
338
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy * 0.5))
339
                elif dx < 0 and dy < 0:
340
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
341
                elif dx < 0 and dy >= 0:
342
                    self._vertices.append(
343
                        (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
344
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
345
                    self._vertices.append(
346
                        (self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
347
                else:
348
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
349
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
350
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
351
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
352
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
353
                if dy < 0:
354
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy * 0.5))
355
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
356
                else:
357
                    self._vertices.append(
358
                        (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
359
                    self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
360
                    self._vertices.append((self._vertices[-1][0],
361
                                           self.connectors[-1].center()[1] + QEngineeringStreamlineItem.MIN_LENGTH))
362
                    self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
363
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
364
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
365
                if dx >= 0 and dy < 0:
366
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
367
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
368
                elif dx < 0 and dy < 0:
369
                    self._vertices.append(
370
                        (self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
371
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
372
                elif dx < 0 and dy >= 0:
373
                    self._vertices.append(
374
                        (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
375
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
376
                else:
377
                    self._vertices.append(
378
                        (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
379
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
380
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
381
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
382
                if dx >= 0:
383
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
384
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
385
                else:
386
                    self._vertices.append(
387
                        (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
388
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
389
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH*2,
390
                                           self._vertices[-1][1]))
391
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
392
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
393
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
394
                if dx >= 0 and dy < 0:
395
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
396
                elif dx < 0 and dy < 0:
397
                    self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
398
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
399
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
400
                elif dx < 0 and dy >= 0:
401
                    self._vertices.append(
402
                        (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
403
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
404
                    self._vertices.append(
405
                        (self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
406
                else:
407
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
408
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
409
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
410
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
411
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
412
                if dx >= 0 and dy < 0:
413
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
414
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
415
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
416
                elif dx < 0 and dy < 0:
417
                    self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
418
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
419
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
420
                elif dx < 0 and dy >= 0:
421
                    self._vertices.append(
422
                        (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
423
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
424
                    self._vertices.append(
425
                        (self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
426
                else:
427
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
428
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
429
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
430
                if dx >= 0 and dy < 0:
431
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
432
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
433
                elif dx < 0 and dy < 0:
434
                    self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
435
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
436
                elif dx < 0 and dy >= 0:
437
                    self._vertices.append(
438
                        (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
439
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
440
                else:
441
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
442
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
443
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
444
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
445
                if dx >= 0 and dy < 0:
446
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
447
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
448
                elif dx < 0 and dy < 0:
449
                    self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
450
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
451
                elif dx < 0 and dy >= 0:
452
                    self._vertices.append(
453
                        (self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
454
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
238
            if self.connectors:
239
                # re-positioning vertex of stream line
240
                self._vertices = []
241

  
242
                self._vertices.append(self.connectors[0].center())
243
                dx = self.connectors[-1].center()[0] - self._vertices[0][0]
244
                dy = self.connectors[-1].center()[1] - self._vertices[0][1]
245
                if (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
246
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
247
                    if dx >= 0 and dy > 0:
248
                        self._vertices.append((self._vertices[0][0], self._vertices[0][1] + dy))
249
                    elif dx < 0 <= dy:
250
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
251
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
252
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
253
                    elif dx < 0 and dy < 0:
254
                        self._vertices.append(
255
                            (self._vertices[0][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
256
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
257
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
258
                    elif dx > 0 > dy:
259
                        self._vertices.append(
260
                            (self._vertices[0][0], self._vertices[0][1] + QEngineeringStreamlineItem.MIN_LENGTH))
261
                        self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
262
                        self._vertices.append((self._vertices[-1][0], self.connectors[-1].center()[1]))
263
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
264
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
265
                    if dx >= 0 and dy < 0:
266
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
267
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
268
                        self._vertices.append((self._vertices[-1][0],
269
                                               self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
270
                    elif dx < 0 and dy < 0:
271
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
272
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
273
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
274
                    elif dx < 0 and dy >= 0:
275
                        self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy))
276
                    elif dx >= 0 and dy >= 0:
277
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
278
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
279
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
280
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
281
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
282
                    if dx >= 0 and dy < 0:
283
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
284
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
285
                        self._vertices.append((self._vertices[-1][0],
286
                                               self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH*2))
287
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
288
                    elif dx < 0 and dy < 0:
289
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
290
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
291
                        self._vertices.append((self._vertices[-1][0],
292
                                               self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH * 2))
293
                        self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
294
                    elif dx < 0 and dy >= 0:
295
                        self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy*0.5))
296
                        self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
297
                    elif dx >= 0 and dy >= 0:
298
                        self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy * 0.5))
299
                        self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
300
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'DOWN') and \
301
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
302
                    if dx >= 0 and dy < 0:
303
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
304
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
305
                    elif dx < 0 and dy < 0:
306
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + QEngineeringStreamlineItem.MIN_LENGTH))
307
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
308
                    elif dx < 0 and dy >= 0:
309
                        self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
310
                        self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
311
                    elif dx >= 0 and dy >= 0:
312
                        self._vertices.append((self._vertices[0][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
313
                        self._vertices.append((self._vertices[0][0] + dx, self._vertices[-1][1]))
314
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
315
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
316
                    if dx >= 0 and dy < 0:
317
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
318
                    elif dx >= 0 and dy >= 0:
319
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
320
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
321
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
322
                    elif dx < 0 and dy >= 0:
323
                        self._vertices.append(
324
                            (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
325
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH , self._vertices[-1][1]))
326
                        self._vertices.append(
327
                            (self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
328
                    else:
329
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
330
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
331
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
332
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
333
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
334
                    if dx >= 0 and dy < 0:
335
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
336
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
337
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy * 0.5))
338
                    elif dx < 0 and dy < 0:
339
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
340
                    elif dx < 0 and dy >= 0:
341
                        self._vertices.append(
342
                            (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
343
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
344
                        self._vertices.append(
345
                            (self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
346
                    else:
347
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
348
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
349
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
350
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
351
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
352
                    if dy < 0:
353
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy * 0.5))
354
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
355
                    else:
356
                        self._vertices.append(
357
                            (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
358
                        self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
359
                        self._vertices.append((self._vertices[-1][0],
360
                                               self.connectors[-1].center()[1] + QEngineeringStreamlineItem.MIN_LENGTH))
361
                        self._vertices.append((self._vertices[-1][0] + dx * 0.5, self._vertices[-1][1]))
362
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'UP') and \
363
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
364
                    if dx >= 0 and dy < 0:
365
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
366
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
367
                    elif dx < 0 and dy < 0:
368
                        self._vertices.append(
369
                            (self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
370
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
371
                    elif dx < 0 and dy >= 0:
372
                        self._vertices.append(
373
                            (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
374
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
375
                    else:
376
                        self._vertices.append(
377
                            (self._vertices[-1][0], self._vertices[-1][1] - QEngineeringStreamlineItem.MIN_LENGTH))
378
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
379
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
380
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
381
                    if dx >= 0:
382
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
383
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
384
                    else:
385
                        self._vertices.append(
386
                            (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
387
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
388
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH*2,
389
                                               self._vertices[-1][1]))
390
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
391
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
392
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
393
                    if dx >= 0 and dy < 0:
394
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
395
                    elif dx < 0 and dy < 0:
396
                        self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
397
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
398
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
399
                    elif dx < 0 and dy >= 0:
400
                        self._vertices.append(
401
                            (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
402
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
403
                        self._vertices.append(
404
                            (self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
405
                    else:
406
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
407
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
408
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
409
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
410
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
411
                    if dx >= 0 and dy < 0:
412
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
413
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
414
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
415
                    elif dx < 0 and dy < 0:
416
                        self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
417
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
418
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
419
                    elif dx < 0 and dy >= 0:
420
                        self._vertices.append(
421
                            (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
422
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
423
                        self._vertices.append(
424
                            (self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
425
                    else:
426
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
427
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'RIGHT') and \
428
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
429
                    if dx >= 0 and dy < 0:
430
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
431
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
432
                    elif dx < 0 and dy < 0:
433
                        self._vertices.append((self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
434
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
435
                    elif dx < 0 and dy >= 0:
436
                        self._vertices.append(
437
                            (self._vertices[-1][0] + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
438
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
439
                    else:
440
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
441
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
442
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
443
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'LEFT'):
444
                    if dx >= 0 and dy < 0:
445
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
446
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
447
                    elif dx < 0 and dy < 0:
448
                        self._vertices.append((self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
449
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
450
                    elif dx < 0 and dy >= 0:
451
                        self._vertices.append(
452
                            (self._vertices[-1][0] + dx - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
453
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
454
                    else:
455
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
456
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
457
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
458
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
459
                    if dx >= 0 and dy < 0:
460
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
461
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
462
                    elif dx < 0 and dy < 0:
463
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
464
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
465
                    elif dx < 0 and dy >= 0:
466
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
467
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
468
                    else:
469
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
470
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
471
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH*2, self._vertices[-1][1]))
472
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
473
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
474
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
475
                    if dx >= 0 and dy < 0:
476
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
477
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
478
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
479
                    elif dx < 0 and dy < 0:
480
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
481
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
482
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
483
                    elif dx < 0 and dy >= 0:
484
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
485
                    else:
486
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
487
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
488
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
489
                elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
490
                        (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
491
                    if dx >= 0 and dy < 0:
492
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
493
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
494
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
495
                    elif dx < 0 and dy < 0:
496
                        self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
497
                    elif dx < 0 and dy >= 0:
498
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
499
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
500
                        self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
501
                    else:
502
                        self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
503
                        self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
504
                        self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
455 505
                else:
456
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
506
                    self._vertices.append((self._vertices[0][0] + dx * 0.5, self._vertices[0][1]))
457 507
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
458
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
459
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'RIGHT'):
460
                if dx >= 0 and dy < 0:
461
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
462
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
463
                elif dx < 0 and dy < 0:
464
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
465
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
466
                elif dx < 0 and dy >= 0:
467
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
468
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
469
                else:
470
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
471
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
472
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH*2, self._vertices[-1][1]))
473
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
474
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
475
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'UP'):
476
                if dx >= 0 and dy < 0:
477
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
478
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
479
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
480
                elif dx < 0 and dy < 0:
481
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
482
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy - QEngineeringStreamlineItem.MIN_LENGTH))
483
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
484
                elif dx < 0 and dy >= 0:
485
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
486
                else:
487
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
488
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
489
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
490
            elif (self.connectors[0].connectedItem and self.connectors[0].connectedItem.direction == 'LEFT') and \
491
                    (self.connectors[-1].connectedItem and self.connectors[-1].connectedItem.direction == 'DOWN'):
492
                if dx >= 0 and dy < 0:
493
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
494
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy*0.5))
495
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
496
                elif dx < 0 and dy < 0:
497
                    self._vertices.append((self._vertices[-1][0] + dx, self._vertices[-1][1]))
498
                elif dx < 0 and dy >= 0:
499
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
500
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
501
                    self._vertices.append((self._vertices[-1][0] + dx*0.5, self._vertices[-1][1]))
502
                else:
503
                    self._vertices.append((self._vertices[-1][0] - QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
504
                    self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy + QEngineeringStreamlineItem.MIN_LENGTH))
505
                    self._vertices.append((self._vertices[-1][0] + dx + QEngineeringStreamlineItem.MIN_LENGTH, self._vertices[-1][1]))
506
            else:
507
                self._vertices.append((self._vertices[0][0] + dx * 0.5, self._vertices[0][1]))
508
                self._vertices.append((self._vertices[-1][0], self._vertices[-1][1] + dy))
509 508

  
510
            self._vertices.append(self.connectors[-1].center())
511
            # up to here
509
                self._vertices.append(self.connectors[-1].center())
510
                # up to here
512 511

  
513 512
            path = QPainterPath()
514 513
            path.moveTo(self._vertices[0][0], self._vertices[0][1])
......
528 527
            self.isCreated = True
529 528

  
530 529
            if self._stream_no_text:
530
                doc = self._stream_no_text.document()
531
                option = doc.defaultTextOption()
532
                option.setAlignment(Qt.AlignCenter)
533
                doc.setDefaultTextOption(option)
531 534
                if max_length_line[0] is not None and max_length_line[1] is not None:
532
                    x = (max_length_line[0][0] + max_length_line[1][0] - self._stream_no_text.textWidth())*0.5
533
                    y = (max_length_line[0][1] + max_length_line[1][1])*0.5
534
                    self._stream_no_text.setPos(QPointF(x, y))
535
                    self._stream_no_text.setTextWidth(doc.idealWidth())
535 536
                    dx = max_length_line[0][0] - max_length_line[1][0]
536 537
                    dy = max_length_line[0][1] - max_length_line[1][1]
537
                    self._stream_no_text.setRotation(90) if abs(dy) > abs(dx) else self._stream_no_text.setRotation(0)
538
                    if abs(dx) >= abs(dy):
539
                        x = (max_length_line[0][0] + max_length_line[1][0] - self._stream_no_text.textWidth())*0.5
540
                        y = (max_length_line[0][1] + max_length_line[1][1])*0.5
541
                        self._stream_no_text.setPos(QPointF(x, y))
542
                        self._stream_no_text.setRotation(0)
543
                    else:
544
                        x = (max_length_line[0][0] + max_length_line[1][0]) * 0.5
545
                        y = (max_length_line[0][1] + max_length_line[1][1] - self._stream_no_text.textWidth()) * 0.5
546
                        self._stream_no_text.setPos(QPointF(x, y))
547
                        self._stream_no_text.setRotation(90)
548

  
549
            self.update_arrow()
538 550
        except Exception as ex:
539 551
            from App import App
540 552
            from AppDocData import MessageType
......
685 697
        """ rebuild stream line """
686 698

  
687 699
        self.build_path()
688
        self.update_arrow()
689 700
        self.update()
690 701

  
691 702
    def mouseDoubleClickEvent(self, event):

내보내기 Unified diff

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