프로젝트

일반

사용자정보

개정판 86b45221

ID86b45221de6041097ba4c546c6dcaf73e3107790
상위 c07e915d
하위 6385e855, 0cbdf0b8

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

issue #505: improve zoom window function with control key

Change-Id: I4d22dc05c6f16ea8f7075774032224044321fb17

차이점 보기:

DTI_PID/DTI_PID/QtImageViewer.py
284 284
    '''
285 285

  
286 286
    def zoomImage(self, isZoomIn, event, adjust=1):
287
        """ Zoom in & out
288
        """
287
        """Zoom in & out """
289 288

  
290 289
        HALF_SIZE = 300
291 290
        clickPos = event.pos()
292 291
        scenePos1 = self.mapToScene(clickPos.x() - HALF_SIZE // adjust, clickPos.y() - HALF_SIZE // adjust)
293 292
        scenePos2 = self.mapToScene(clickPos.x() + HALF_SIZE // adjust, clickPos.y() + HALF_SIZE // adjust)
294 293
        if isZoomIn:
295
            zoomArea = QRectF(
296
                QPointF(scenePos1.x() if scenePos1.x() > 0 else 0, scenePos1.y() if scenePos1.y() > 0 else 0),
297
                QPointF(scenePos2.x(), scenePos2.y()))
298
            # self.fitInView(zoomArea, Qt.KeepAspectRatioByExpanding)
294
            zoomArea = QRectF(scenePos1, scenePos2)
299 295
            viewBBox = self.zoomStack[-1] if len(self.zoomStack) else self.sceneRect()
300 296
            selectionBBox = zoomArea.intersected(viewBBox)
301 297
            self.scene.setSelectionArea(QPainterPath())  # Clear current selection area.
302
            if selectionBBox.width() > HALF_SIZE * 2 and selectionBBox.height() > HALF_SIZE * 2:
303
                if selectionBBox.isValid() and (selectionBBox != viewBBox):
304
                    self.zoomStack.append(selectionBBox)
305
                    self.updateViewer()
298
            if selectionBBox.isValid() and (selectionBBox != viewBBox):
299
                self.zoomStack.append(selectionBBox)
300
                self.updateViewer()
306 301
        else:
307 302
            zoomNewRect = None
308 303
            self.scene.setSelectionArea(QPainterPath())  # Clear current selection area.
309
            if len(self.zoomStack):
310
                self.zoomStack.pop()
311
            if len(self.zoomStack):
312
                newScenePos = self.mapToScene(clickPos.x(), clickPos.y())
313
                newPosX1 = newScenePos.x() - self.zoomStack[-1].width() / 2
314
                newPosY1 = newScenePos.y() - self.zoomStack[-1].height() / 2
315
                zoomNewPos1 = QPointF(newPosX1 if newPosX1 > 0 else 0, newPosY1 if newPosY1 > 0 else 0)
316
                newPosX2 = newScenePos.x() + self.zoomStack[-1].width() / 2
317
                newPosY2 = newScenePos.y() + self.zoomStack[-1].width() / 2
318
                zoomNewPos2 = QPointF(newPosX2, newPosY2)
319
                zoomNewRect = QRectF(zoomNewPos1, zoomNewPos2)
304
            if self.zoomStack:
305
                zoomNewRect = self.zoomStack.pop()
320 306
            self.updateViewer(zoomNewRect)
321 307

  
322 308
    def resizeEvent(self, event):
323
        """ Maintain current zoom on resize.
324
        """
309
        """Maintain current zoom on resize"""
325 310
        self.updateViewer()
326 311

  
327 312
    '''

내보내기 Unified diff

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