From 2dfb6476c4af26b0b3fa565136c8388aa08d2d6f Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Tue, 1 Apr 2025 07:15:18 +0200 Subject: [PATCH 1/5] fix export zoom percentage bug corrects issue where zoom percentages were being stored as a multiplier, meaning the image size was shrinking with each export --- plotdevice/gui/widgets.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plotdevice/gui/widgets.py b/plotdevice/gui/widgets.py index 397e3d7..d8e9639 100644 --- a/plotdevice/gui/widgets.py +++ b/plotdevice/gui/widgets.py @@ -376,6 +376,9 @@ def beginExport(self, kind): format = self.image['format'] accessory = self.imageAccessory + # Set the zoom value so that UI reflects the previously stored value + self.imageZoom.setStringValue_("%i%%" % self.image['zoom']) + if self.image['single']: self.imageFormat.selectItemAtIndex_(1) else: @@ -442,7 +445,17 @@ def exportPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, context): kind, opts = 'movie', self.movieState() else: kind, opts = 'image', self.imageState() - setattr(self, kind, dict(opts)) # save the options for next time + + # Convert zoom multiplier back to percentage before saving + saved_opts = dict(opts) + if 'zoom' in saved_opts: + saved_opts['zoom'] = saved_opts['zoom'] * 100 + + # Save the modified options (with percentage zoom) + setattr(self, kind, saved_opts) + print("Export options:", saved_opts) + + # Continue with the export using the original options (with decimal zoom) self.last = os.path.split(fname) # save the path we exported to self.script.exportInit(kind, fname, opts) From cf58a78e84dd16032157e8d14454cbbcf17285f9 Mon Sep 17 00:00:00 2001 From: flimsyhat Date: Tue, 1 Apr 2025 12:17:59 +0200 Subject: [PATCH 2/5] remove print debugging --- plotdevice/gui/widgets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plotdevice/gui/widgets.py b/plotdevice/gui/widgets.py index d8e9639..24ada23 100644 --- a/plotdevice/gui/widgets.py +++ b/plotdevice/gui/widgets.py @@ -453,7 +453,6 @@ def exportPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, context): # Save the modified options (with percentage zoom) setattr(self, kind, saved_opts) - print("Export options:", saved_opts) # Continue with the export using the original options (with decimal zoom) self.last = os.path.split(fname) # save the path we exported to From 13c0624dbb985996021409e29422fbf60185f69a Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Fri, 23 May 2025 12:47:48 -0400 Subject: [PATCH 3/5] Revert "remove print debugging" This reverts commit cf58a78e84dd16032157e8d14454cbbcf17285f9. --- plotdevice/gui/widgets.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plotdevice/gui/widgets.py b/plotdevice/gui/widgets.py index 24ada23..d8e9639 100644 --- a/plotdevice/gui/widgets.py +++ b/plotdevice/gui/widgets.py @@ -453,6 +453,7 @@ def exportPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, context): # Save the modified options (with percentage zoom) setattr(self, kind, saved_opts) + print("Export options:", saved_opts) # Continue with the export using the original options (with decimal zoom) self.last = os.path.split(fname) # save the path we exported to From 46111c5fe64d061c3d233ab71227ebf74b013553 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Fri, 23 May 2025 12:47:52 -0400 Subject: [PATCH 4/5] Revert "fix export zoom percentage bug" This reverts commit 2dfb6476c4af26b0b3fa565136c8388aa08d2d6f. --- plotdevice/gui/widgets.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/plotdevice/gui/widgets.py b/plotdevice/gui/widgets.py index d8e9639..397e3d7 100644 --- a/plotdevice/gui/widgets.py +++ b/plotdevice/gui/widgets.py @@ -376,9 +376,6 @@ def beginExport(self, kind): format = self.image['format'] accessory = self.imageAccessory - # Set the zoom value so that UI reflects the previously stored value - self.imageZoom.setStringValue_("%i%%" % self.image['zoom']) - if self.image['single']: self.imageFormat.selectItemAtIndex_(1) else: @@ -445,17 +442,7 @@ def exportPanelDidEnd_returnCode_contextInfo_(self, panel, returnCode, context): kind, opts = 'movie', self.movieState() else: kind, opts = 'image', self.imageState() - - # Convert zoom multiplier back to percentage before saving - saved_opts = dict(opts) - if 'zoom' in saved_opts: - saved_opts['zoom'] = saved_opts['zoom'] * 100 - - # Save the modified options (with percentage zoom) - setattr(self, kind, saved_opts) - print("Export options:", saved_opts) - - # Continue with the export using the original options (with decimal zoom) + setattr(self, kind, dict(opts)) # save the options for next time self.last = os.path.split(fname) # save the path we exported to self.script.exportInit(kind, fname, opts) From 99600817abc75a0c9237bb27827fbe28acf28a58 Mon Sep 17 00:00:00 2001 From: Christian Swinehart Date: Fri, 23 May 2025 12:53:04 -0400 Subject: [PATCH 5/5] fix zoom unit conversion - the `self.image["zoom"]` state field now uses 1.0 as 100% - the `self.imageZoom` outlet uses "100" as 100% - when exiting the modal, the zoom value is now persisted correctly (rather than accidentally being divided by 100) --- plotdevice/gui/widgets.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plotdevice/gui/widgets.py b/plotdevice/gui/widgets.py index 397e3d7..3c93b59 100644 --- a/plotdevice/gui/widgets.py +++ b/plotdevice/gui/widgets.py @@ -365,10 +365,9 @@ class ExportSheet(NSObject): def awakeFromNib(self): self.formats = dict(image=(0, 'pdf', 0,0, 'png', 'jpg', 'heic', 'tiff', 'gif', 0,0, 'pdf', 'eps'), movie=('mov', 'mov', 'gif')) self.movie = dict(format='mov', first=1, last=150, fps=30, bitrate=1, loop=0, codec=0) - self.image = dict(format='pdf', zoom=100, first=1, last=1, cmyk=False, single=True) + self.image = dict(format='pdf', zoom=1.0, first=1, last=1, cmyk=False, single=True) self.last = None - @objc.python_method def beginExport(self, kind): # configure the accessory controls @@ -464,7 +463,7 @@ def imageState(self, key=None): fmts = self.formats['image'] fmt_idx = self.imageFormat.indexOfSelectedItem() state = dict(format=fmts[fmt_idx], - zoom=self.image['zoom'] / 100, + zoom=self.image['zoom'], first=1, cmyk=self.imageCMYK.state()==NSOnState, single=fmt_idx==1, @@ -497,7 +496,7 @@ def imageZoomStepped_(self, sender): sender.setIntValue_(0) self.imageZoomChanged_(None) # reflect any editing in text field - pct = self.image['zoom'] + pct = self.image['zoom'] * 100 if step > 0: pct = 100 * ceil((pct + 1) / 100) @@ -505,16 +504,16 @@ def imageZoomStepped_(self, sender): pct = 100 * floor((pct - 1) / 100) if 0 < pct < 10000: - self.image['zoom'] = pct + self.image['zoom'] = pct / 100 self.imageZoom.setStringValue_("%i%%" % pct) @IBAction def imageZoomChanged_(self, sender): pct = self.imageZoom.intValue() if pct > 0: - self.image['zoom'] = pct + self.image['zoom'] = pct / 100 else: - pct = self.image['zoom'] + pct = self.image['zoom'] * 100 self.imageZoom.setStringValue_("%i%%" % pct) @IBAction