개정판 e7e6914b
issue #505: improve zoom ongoing
Change-Id: I51204fb162c0d090842000783712418b1a5a215c
DTI_PID/DTI_PID/Commands/AreaZoomCommand.py | ||
---|---|---|
59 | 59 |
if event.button() == Qt.LeftButton: |
60 | 60 |
self.isLeftClicked = False |
61 | 61 |
if self.imageViewer.canZoom and event.button() == Qt.LeftButton: |
62 |
if not self.imageViewer.zoomStack: |
|
63 |
self.imageViewer.zoomStack.append(self.imageViewer.sceneRect()) |
|
64 |
|
|
62 | 65 |
self._rubberBand.hide() |
63 | 66 |
topLeft = self.imageViewer.mapToScene(self._rubberBand.geometry().topLeft()) |
64 | 67 |
bottomRight = self.imageViewer.mapToScene(self._rubberBand.geometry().bottomRight()) |
65 | 68 |
rect = QRectF(topLeft.x(), topLeft.y(), |
66 | 69 |
bottomRight.x() - topLeft.x(), bottomRight.y() - topLeft.y()) |
70 |
|
|
71 |
current_rect = self.imageViewer.zoomStack[-1] |
|
72 |
current_area = current_rect.width() * current_rect.height() |
|
73 |
new_area = rect.width() * rect.height() |
|
74 |
area_ratio = 100 - (new_area / current_area * 100) |
|
75 |
zoomStack_count = int(area_ratio / 25) |
|
76 |
if zoomStack_count > 0: |
|
77 |
current_center = current_rect.center() |
|
78 |
new_center = rect.center() |
|
79 |
|
|
80 |
dx = new_center.x() - current_center.x() |
|
81 |
dy = new_center.y() - current_center.y() |
|
82 |
ddx = dx / (zoomStack_count + 1) |
|
83 |
ddy = dy / (zoomStack_count + 1) |
|
84 |
|
|
85 |
dw = current_rect.width() - rect.width() |
|
86 |
dh = current_rect.height() - rect.height() |
|
87 |
ddw = dw / (zoomStack_count + 1) |
|
88 |
ddh = dh / (zoomStack_count + 1) |
|
89 |
|
|
90 |
for index in range(zoomStack_count): |
|
91 |
add_center = QPointF(current_center.x() + (index + 1) * ddx, current_center.y() + (index + 1) * ddy) |
|
92 |
add_width = current_rect.width() - (index + 1) * ddw |
|
93 |
add_height = current_rect.height() - (index + 1) * ddh |
|
94 |
|
|
95 |
x1 = add_center.x() - add_width / 2 |
|
96 |
y1 = add_center.y() - add_height / 2 |
|
97 |
x2 = add_center.x() + add_width / 2 |
|
98 |
y2 = add_center.y() + add_height / 2 |
|
99 |
|
|
100 |
add_stack = QRectF(x1, y1, x2,y2) |
|
101 |
self.imageViewer.zoomStack.append(add_stack) |
|
102 |
|
|
67 | 103 |
self.imageViewer.zoomStack.append(rect) |
68 | 104 |
self.imageViewer.updateViewer(rect) |
69 | 105 |
elif Qt.RightButton == event.button(): |
내보내기 Unified diff