프로젝트

일반

사용자정보

개정판 dec3a5e2

IDdec3a5e23ef7adc7fa485b831b10808d9f90b195
상위 bdeaf9ad
하위 3e7012a0

함의성이(가) 10달 전에 추가함

add symbol flip option

Change-Id: I56a2d1fe4d2cba98cf4e70f63888cfe83357b9de

차이점 보기:

DTI_PID/DTI_PID/Commands/FlipCommand.py
7 7
from PyQt5.QtCore import *
8 8
from PyQt5.QtGui import *
9 9
from PyQt5.QtWidgets import *
10
from AppDocData import AppDocData
11
import math
10 12

  
11 13

  
12 14
class FlipCommand(QUndoCommand):
13 15
    def __init__(self, scene, items, parent=None):
14
        from SymbolSvgItem import SymbolSvgItem
15

  
16 16
        super(FlipCommand, self).__init__(parent)
17 17
        self._scene = scene
18 18
        self._items = [item for item in items if issubclass(type(item), SymbolSvgItem) and
......
23 23
    def undo(self):
24 24
        """undo"""
25 25
        for idx, item in enumerate(self._items):
26
            item.flip = self._params[idx]
27
            item.flip_symbol()
26
            _flip = self._params[idx]
27
            if _flip != -1:
28
                item.flip = _flip
29
                item.flip_symbol()
28 30

  
29 31
        self._scene.update()
30 32

  
......
33 35
    def redo(self):
34 36
        """redo"""
35 37
        if not self._flipped:
38
            configs = AppDocData.instance().getConfigs('Data', 'Flip')
39
            flip = int(configs[0].value) if 1 == len(configs) else 1
40

  
41
            configs = AppDocData.instance().getConfigs('Flip', 'Symbol')
42
            symbols = configs[0].value if 1 == len(configs) else ''
43
            symbols = [name.strip() for name in symbols.split(',')]
44

  
36 45
            _params = []
37 46
            for idx, item in enumerate(self._items):
38
                _params.append(item.flip)
39
                item.flip = 0 if item.flip else 1
40
                item.flip_symbol()
47
                if item.flip == 1 or flip == 1 or (flip == -1 and item.name in symbols):
48
                    _params.append(item.flip)
49
                    item.flip = 0 if item.flip else 1
50
                    item.flip_symbol()
51
                else:
52
                    _params.append(-1)
53
                    angle = item.rotation()
54
                    item.rotate(math.radians((angle + 90) % 360 if angle in [0, 90, 180, 270, 360] else 0))
55
                    angle = item.rotation()
56
                    item.rotate(math.radians((angle + 90) % 360 if angle in [0, 90, 180, 270, 360] else 0))
41 57

  
42 58
            self._params = _params
43 59
            self._scene.update()

내보내기 Unified diff

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