Add scale settings

This commit is contained in:
Fierelier 2023-08-24 20:47:02 +02:00
parent 84ca8068ee
commit c8aacaec4a

View File

@ -69,6 +69,8 @@ defaultProfile["stretch"] = True
defaultProfile["rotate"] = True defaultProfile["rotate"] = True
defaultProfile["offset-x"] = 0 defaultProfile["offset-x"] = 0
defaultProfile["offset-y"] = 0 defaultProfile["offset-y"] = 0
defaultProfile["scale-x"] = 1.00
defaultProfile["scale-y"] = 1.00
# Profiles # Profiles
def saveProfile(profile,profileName): def saveProfile(profile,profileName):
@ -245,7 +247,7 @@ class mainWindow(QMainWindow):
self.cTitle = prettyDistro self.cTitle = prettyDistro
self.setWindowTitle(self.cTitle) self.setWindowTitle(self.cTitle)
self.cWidth = 300 self.cWidth = 300
self.cHeight = 256 self.cHeight = 265
self.resize(self.cWidth,self.cHeight) self.resize(self.cWidth,self.cHeight)
self.cCreateElements() self.cCreateElements()
@ -281,6 +283,8 @@ class mainWindow(QMainWindow):
self.cStretchTick.setChecked(self.cProfile["stretch"]) self.cStretchTick.setChecked(self.cProfile["stretch"])
self.cOffsetHorzInput.setText(str(self.cProfile["offset-x"])) self.cOffsetHorzInput.setText(str(self.cProfile["offset-x"]))
self.cOffsetVertInput.setText(str(self.cProfile["offset-y"])) self.cOffsetVertInput.setText(str(self.cProfile["offset-y"]))
self.cScaleHorzInput.setText(str(self.cProfile["scale-x"]))
self.cScaleVertInput.setText(str(self.cProfile["scale-y"]))
def cSaveProfile(self): def cSaveProfile(self):
self.setEnabled(False) self.setEnabled(False)
@ -332,6 +336,10 @@ class mainWindow(QMainWindow):
profile["offset-x"] = int(self.cOffsetHorzInput.text()) profile["offset-x"] = int(self.cOffsetHorzInput.text())
error = "Offset vertical" error = "Offset vertical"
profile["offset-y"] = int(self.cOffsetVertInput.text()) profile["offset-y"] = int(self.cOffsetVertInput.text())
error = "Scale horizontal"
profile["scale-x"] = float(self.cScaleHorzInput.text())
error = "Scale vertical"
profile["scale-y"] = float(self.cScaleVertInput.text())
except: except:
return error return error
return profile return profile
@ -398,8 +406,8 @@ class mainWindow(QMainWindow):
imStartY = printerPrintOffset[1] imStartY = printerPrintOffset[1]
if profile["stretch"]: if profile["stretch"]:
imEndX = imStartX + printerPrintSize[0] imEndX = printerPrintSize[0]
imEndY = imStartY + printerPrintSize[1] imEndY = printerPrintSize[1]
else: else:
imEndX = imStartX + bmp.size[0] imEndX = imStartX + bmp.size[0]
imEndY = imStartY + bmp.size[1] imEndY = imStartY + bmp.size[1]
@ -409,6 +417,13 @@ class mainWindow(QMainWindow):
imStartY += profile["offset-y"] imStartY += profile["offset-y"]
imEndY += profile["offset-y"] imEndY += profile["offset-y"]
addX = round((imEndX - imStartX) * profile["scale-x"]) - (imEndX - imStartX)
addY = round((imEndY - imStartY) * profile["scale-y"]) - (imEndY - imStartY)
imEndX = imEndX + (round(addX*0.5))
imEndY = imEndY + (round(addY*0.5))
imStartX = imStartX - (round(addX*0.5))
imStartY = imStartY - (round(addY*0.5))
copies = profile["amount"] copies = profile["amount"]
dib = PIL.ImageWin.Dib(bmp) dib = PIL.ImageWin.Dib(bmp)
while copies > 0: while copies > 0:
@ -502,7 +517,7 @@ class mainWindow(QMainWindow):
# Offset horizontal # Offset horizontal
layout = self.cCreateLayout() layout = self.cCreateLayout()
self.cOffsetHorzLabel = QLabel("Offset horizontal:") self.cOffsetHorzLabel = QLabel("Offset horizontal (px):")
#self.cOffsetHorzLabel.setStyleSheet("font-weight: bold") #self.cOffsetHorzLabel.setStyleSheet("font-weight: bold")
layout.addWidget(self.cOffsetHorzLabel) layout.addWidget(self.cOffsetHorzLabel)
line = createLine() line = createLine()
@ -512,7 +527,7 @@ class mainWindow(QMainWindow):
# Offset vertical # Offset vertical
layout = self.cCreateLayout() layout = self.cCreateLayout()
self.cOffsetVertLabel = QLabel("Offset vertical:") self.cOffsetVertLabel = QLabel("Offset vertical (px):")
#self.cOffsetVertLabel.setStyleSheet("font-weight: bold") #self.cOffsetVertLabel.setStyleSheet("font-weight: bold")
layout.addWidget(self.cOffsetVertLabel) layout.addWidget(self.cOffsetVertLabel)
line = createLine() line = createLine()
@ -520,6 +535,26 @@ class mainWindow(QMainWindow):
self.cOffsetVertInput = QLineEdit() self.cOffsetVertInput = QLineEdit()
layout.addWidget(self.cOffsetVertInput) layout.addWidget(self.cOffsetVertInput)
# Scale horizontal
layout = self.cCreateLayout()
self.cScaleHorzLabel = QLabel("Scale horizontal (*):")
#self.cScaleHorzLabel.setStyleSheet("font-weight: bold")
layout.addWidget(self.cScaleHorzLabel)
line = createLine()
layout.addWidget(line)
self.cScaleHorzInput = QLineEdit()
layout.addWidget(self.cScaleHorzInput)
# Scale vertical
layout = self.cCreateLayout()
self.cScaleVertLabel = QLabel("Scale vertical (*):")
#self.cScaleVertLabel.setStyleSheet("font-weight: bold")
layout.addWidget(self.cScaleVertLabel)
line = createLine()
layout.addWidget(line)
self.cScaleVertInput = QLineEdit()
layout.addWidget(self.cScaleVertInput)
line = createLine("solid") line = createLine("solid")
self.cLayout.addWidget(line) self.cLayout.addWidget(line)
@ -587,6 +622,14 @@ class mainWindow(QMainWindow):
limitWidgetSize(self.cOffsetVertLabel) limitWidgetSize(self.cOffsetVertLabel)
self.cOffsetVertInput.setMaximumWidth(64) self.cOffsetVertInput.setMaximumWidth(64)
# Scale horizontal
limitWidgetSize(self.cScaleHorzLabel)
self.cScaleHorzInput.setMaximumWidth(64)
# Scale vertical
limitWidgetSize(self.cScaleVertLabel)
self.cScaleVertInput.setMaximumWidth(64)
# Information # Information
limitWidgetSize(self.cInfoResolutionLabel) limitWidgetSize(self.cInfoResolutionLabel)
limitWidgetSize(self.cInfoResolutionValue) limitWidgetSize(self.cInfoResolutionValue)