Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Function to zoom in corners with hotkeys #670

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion labelImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ def getFormatMeta(format):
fitWidth = action(getStr('fitWidth'), self.setFitWidth,
'Ctrl+Shift+F', 'fit-width', getStr('fitWidthDetail'),
checkable=True, enabled=False)

# Zoom in corners
zoomLeftTop = action(getStr('zoomLT'), self.zoomLeftTop,
'1', 'left-top', getStr('zoomLT'))
zoomRightTop = action(getStr('zoomRT'), self.zoomRightTop,
'2', 'right-top', getStr('zoomRT'))
zoomRightBottom = action(getStr('zoomRB'), self.zoomRightBottom,
'3', 'right-bottom', getStr('zoomRB'))
zoomLeftBottom = action(getStr('zoomLB'), self.zoomLeftBottom,
'4', 'left-bottom', getStr('zoomLB'))

# Group zoom controls into a list for easier toggling.
zoomActions = (self.zoomWidget, zoomIn, zoomOut,
zoomOrg, fitWindow, fitWidth)
Expand Down Expand Up @@ -405,7 +416,8 @@ def getFormatMeta(format):
labels, advancedMode, None,
hideAll, showAll, None,
zoomIn, zoomOut, zoomOrg, None,
fitWindow, fitWidth))
fitWindow, fitWidth, None,
zoomLeftTop, zoomRightTop, zoomRightBottom, zoomLeftBottom))

self.menus.file.aboutToShow.connect(self.updateFileMenu)

Expand Down Expand Up @@ -958,6 +970,30 @@ def setZoom(self, value):
def addZoom(self, increment=10):
self.setZoom(self.zoomWidget.value() + increment)

def zoomLeftTop(self):
self.setZoom(300)
h_bar = self.scrollBars[Qt.Horizontal].setValue(0)
v_bar = self.scrollBars[Qt.Vertical].setValue(0)

def zoomRightTop(self):
self.setZoom(300)
h_bar = self.scrollBars[Qt.Horizontal]
v_bar = self.scrollBars[Qt.Vertical].setValue(0)
h_bar.setValue(h_bar.maximum())

def zoomRightBottom(self):
self.setZoom(300)
h_bar = self.scrollBars[Qt.Horizontal]
v_bar = self.scrollBars[Qt.Vertical]
h_bar.setValue(h_bar.maximum())
v_bar.setValue(v_bar.maximum())

def zoomLeftBottom(self):
self.setZoom(300)
h_bar = self.scrollBars[Qt.Horizontal].setValue(0)
v_bar = self.scrollBars[Qt.Vertical]
v_bar.setValue(v_bar.maximum())

def zoomRequest(self, delta):
# get the current scrollbar positions
# calculate the percentages ~ coordinates
Expand Down
4 changes: 4 additions & 0 deletions resources/strings/strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ fitWin=Fit Window
fitWinDetail=Zoom follows window size
fitWidth=Fit Width
fitWidthDetail=Zoom follows window width
zoomLT=Zoom left top corner
zoomRT=Zoom right top corner
zoomRB=Zoom right bottom corner
zoomLB=Zoom left bottom corner
editLabel=Edit Label
editLabelDetail=Modify the label of the selected Box
shapeLineColor=Shape Line Color
Expand Down