개정판 03940dd1
issue #1059: fixed FlipCommand and SymbolSvgItem
Change-Id: Iff8e75f78d8ac27a751add46168e6749bb409721
HYTOS/HYTOS/Commands/FlipCommand.py | ||
---|---|---|
23 | 23 |
def undo(self): |
24 | 24 |
"""undo""" |
25 | 25 |
for idx, item in enumerate(self._items): |
26 |
item.flip = self._params[idx] |
|
26 |
#item.flip = self._params[idx]
|
|
27 | 27 |
item.flip_symbol(self._flip == 1) |
28 | 28 |
|
29 | 29 |
self._scene.update() |
... | ... | |
35 | 35 |
if not self._flipped: |
36 | 36 |
_params = [] |
37 | 37 |
for idx, item in enumerate(self._items): |
38 |
_params.append(item.flip) # save original flip code |
|
38 |
#_params.append(item.flip) # save original flip code
|
|
39 | 39 |
item.flip_symbol(self._flip == 1) |
40 | 40 |
|
41 | 41 |
self._params = _params |
HYTOS/HYTOS/Shapes/SymbolSvgItem.py | ||
---|---|---|
213 | 213 |
|
214 | 214 |
try: |
215 | 215 |
rect = self.sceneBoundingRect() |
216 |
origin = self.mapToScene(self.transformOriginPoint()) |
|
217 |
trans = self.transform() |
|
216 | 218 |
|
217 | 219 |
cols = ['UID', 'Symbols_UID', 'Name', '[Index]', 'X', 'Y', 'Rotation', 'ScaleX', 'ScaleY'] |
218 | 220 |
values = ['?', '?', '?', '?', '?', '?', '?', '?', '?'] |
219 | 221 |
param = [str(self.uid), str(self.dbUid), str(self.tag_no) if self.tag_no is not None else self.tag_no, |
220 |
self.index, rect.left(), rect.top(),
|
|
221 |
str(self.angle), self.scale(), self.scale()]
|
|
222 |
self.index, origin.x(), origin.y(),
|
|
223 |
self.rotation(), trans.m11(), trans.m22()]
|
|
222 | 224 |
sql = 'insert or replace into Components({}) values({})'.format(','.join(cols), ','.join(values)) |
223 | 225 |
res.append((sql, tuple(param))) |
224 | 226 |
|
... | ... | |
237 | 239 |
except Exception as ex: |
238 | 240 |
from App import App |
239 | 241 |
|
240 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
241 |
sys.exc_info()[-1].tb_lineno)
|
|
242 |
message = f'error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \
|
|
243 |
f'{sys.exc_info()[-1].tb_lineno}'
|
|
242 | 244 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
243 | 245 |
|
244 | 246 |
return res |
... | ... | |
1353 | 1355 |
|
1354 | 1356 |
return super().itemChange(change, value) |
1355 | 1357 |
|
1356 |
''' |
|
1357 |
@brief remove item when user press delete key |
|
1358 |
@author humkyung |
|
1359 |
@date 2018.04.23 |
|
1360 |
@history 2018.05.17 Jeongwoo Add if-statement and move 'break' |
|
1361 |
2018.05.25 Jeongwoo Seperate delete item method |
|
1362 |
''' |
|
1363 |
|
|
1364 | 1358 |
def keyPressEvent(self, event): |
1359 |
"""key event handler""" |
|
1365 | 1360 |
if not self.isSelected(): return |
1366 | 1361 |
|
1367 | 1362 |
if event.key() == Qt.Key_Delete: |
1368 | 1363 |
self.deleteSvgItemFromScene() |
1369 | 1364 |
elif event.key() == Qt.Key_QuoteLeft: |
1370 | 1365 |
self.mouseDoubleClickEvent(event) |
1366 |
elif event.key() == Qt.Key_H: |
|
1367 |
from FlipCommand import FlipCommand |
|
1368 |
|
|
1369 |
try: |
|
1370 |
viewer = App.mainWnd().graphicsView |
|
1371 |
items = viewer.scene.selectedItems() |
|
1372 |
if items: |
|
1373 |
viewer.scene.undo_stack.push(FlipCommand(viewer.scene, items, flip=1)) |
|
1374 |
except Exception as ex: |
|
1375 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
1376 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
1377 |
|
|
1378 |
self.addMessage.emit(MessageType.Error, message) |
|
1379 |
elif event.key() == Qt.Key_V: |
|
1380 |
from FlipCommand import FlipCommand |
|
1381 |
|
|
1382 |
try: |
|
1383 |
viewer = App.mainWnd().graphicsView |
|
1384 |
items = viewer.scene.selectedItems() |
|
1385 |
if items: |
|
1386 |
viewer.scene.undo_stack.push(FlipCommand(viewer.scene, items, flip=2)) |
|
1387 |
except Exception as ex: |
|
1388 |
message = f"error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:" \ |
|
1389 |
f"{sys.exc_info()[-1].tb_lineno}" |
|
1390 |
|
|
1391 |
self.addMessage.emit(MessageType.Error, message) |
|
1392 |
|
|
1371 | 1393 |
|
1372 | 1394 |
''' |
1373 | 1395 |
@brief Double click event, Show rotate symbol dialog |
... | ... | |
1743 | 1765 |
y = componentInfos[0]['Comp_Y'] # Y@Components |
1744 | 1766 |
angle = componentInfos[0]['Rotation'] # Rotation@Components |
1745 | 1767 |
#scale = componentInfos[0]['Scale'] # Scale@Components |
1746 |
scales = [float(componentInfos[0]['ScaleX'], float(componentInfos[0]['ScaleY'])) # scale x, scale y
|
|
1768 |
scales = [float(componentInfos[0]['ScaleX']), float(componentInfos[0]['ScaleY'])] # scale x, scale y
|
|
1747 | 1769 |
|
1748 | 1770 |
pt = [] |
1749 | 1771 |
pt.append(float(x)) |
... | ... | |
1766 | 1788 |
|
1767 | 1789 |
except Exception as ex: |
1768 | 1790 |
from App import App |
1769 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
1770 |
sys.exc_info()[-1].tb_lineno)
|
|
1791 |
message = f'error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \
|
|
1792 |
f'{sys.exc_info()[-1].tb_lineno}'
|
|
1771 | 1793 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1772 | 1794 |
|
1773 | 1795 |
return item |
... | ... | |
1928 | 1950 |
self.setTransform(trans) |
1929 | 1951 |
self.rotate(self.angle) |
1930 | 1952 |
pt = trans.map(self.symbolOrigin[0], self.symbolOrigin[1]) |
1931 |
self.setPos(self.origin[0] - pt[0], self.origin[1] - pt[1])
|
|
1953 |
self.setPos(self.loc[0] - pt[0], self.loc[1] - pt[1])
|
|
1932 | 1954 |
|
1933 | 1955 |
# scale down for label |
1956 |
""" |
|
1934 | 1957 |
trans = QTransform() |
1935 |
trans.scale(1/ self._scales[0], 1 / self._scales[1]) |
|
1958 |
trans.scale(1 / self._scales[0], 1 / self._scales[1])
|
|
1936 | 1959 |
for conn, label in self.desc_labels.items(): |
1937 | 1960 |
label.setTransform(trans) |
1961 |
""" |
|
1938 | 1962 |
# up to here |
1939 | 1963 |
except Exception as ex: |
1940 | 1964 |
from App import App |
... | ... | |
1976 | 2000 |
from App import App |
1977 | 2001 |
from AppDocData import MessageType |
1978 | 2002 |
|
1979 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
1980 |
sys.exc_info()[-1].tb_lineno)
|
|
2003 |
message = f'error occurred({repr(ex)}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \
|
|
2004 |
f'{sys.exc_info()[-1].tb_lineno}'
|
|
1981 | 2005 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
1982 | 2006 |
|
1983 | 2007 |
self.transfer.onRemoved.emit(self) |
내보내기 Unified diff