From 7b747b49648a5e477a08940e644f05d3ef7816b6 Mon Sep 17 00:00:00 2001
From: wgilster <wesgilster@gmail.com>
Date: Sat, 15 Oct 2016 20:23:24 -0500
Subject: [PATCH 1/2] Zslicer was reporting an incorrect X/Y aspect ratio

---
 host/resourcesnew/cwh/js/printables.js                    | 8 ++++++--
 host/resourcesnew/printables.html                         | 4 ++--
 .../org/area515/resinprinter/services/PrinterService.java | 2 +-
 .../main/java/org/area515/resinprinter/slice/ZSlicer.java | 2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/host/resourcesnew/cwh/js/printables.js b/host/resourcesnew/cwh/js/printables.js
index d3032ec11..fe3eb379e 100644
--- a/host/resourcesnew/cwh/js/printables.js
+++ b/host/resourcesnew/cwh/js/printables.js
@@ -62,6 +62,7 @@
 									zscale: 1,
 									nextSlice: 0,
 									nextStep: "PerformHeader",
+									imageManipulationCalculator: null,
 									affineTransformSettings: {
 										yflip: false,
 										xflip: false,
@@ -71,7 +72,8 @@
 										xtranslate: 0,
 										ytranslate: 0,
 										xshear: 0,
-										yshear: 0
+										yshear: 0,
+										affineTransformScriptCalculator: null
 									}
 								};
 						} else {
@@ -172,7 +174,8 @@
 			controller.currentCustomizer.zscale = 1.0;
 			controller.currentCustomizer.nextSlice = 0;
 			controller.currentCustomizer.nextStep = "PerformHeader";
-
+			controller.currentCustomizer.imageManipulationCalculator = null;
+			
 			var affineTransformSettings = controller.currentCustomizer.affineTransformSettings;
 			affineTransformSettings.xtranslate = 0;
 			affineTransformSettings.ytranslate = 0;
@@ -183,6 +186,7 @@
 			affineTransformSettings.xflip = false;
 			affineTransformSettings.yflip = false;
 			affineTransformSettings.rotation = 0;
+			affineTransformSettings.affineTransformScriptCalculator = null;
 			this.saveCustomizer();
 		}
 
diff --git a/host/resourcesnew/printables.html b/host/resourcesnew/printables.html
index 31fd6b989..30f0eb564 100644
--- a/host/resourcesnew/printables.html
+++ b/host/resourcesnew/printables.html
@@ -260,12 +260,12 @@ <h4>Duplication grid</h4>
 
 						</div>
 						<div class="list-group-item">
-				 			<i class="fa fa-2x fa-th-large pull-left"></i>						
+				 			<i class="fa fa-2x fa-paint-brush pull-left"></i>						
 							<h4>Image Manipulation Calculator</h4>
 
 						</div>
 						<div class="list-group-item">
-				 			<i class="fa fa-2x fa-th-large pull-left"></i>						
+				 			<i class="fa fa-2x fa-map-o pull-left"></i>						
 							<h4>AffineTransform Calculator</h4>
 
 						</div>
diff --git a/host/src/main/java/org/area515/resinprinter/services/PrinterService.java b/host/src/main/java/org/area515/resinprinter/services/PrinterService.java
index 7a4798995..2ef423baf 100644
--- a/host/src/main/java/org/area515/resinprinter/services/PrinterService.java
+++ b/host/src/main/java/org/area515/resinprinter/services/PrinterService.java
@@ -444,7 +444,7 @@ PrinterConfiguration createTemplatePrinter(String printername, String displayId,
 		
 		TwoDimensionalSettings settings = new TwoDimensionalSettings();
 		settings.setFont(DEFAULT_FONT);
-		settings.setPlatformCalculator("platformGraphics.fillRoundRect(centerX - (extrusionX / 2), centerY - (extrusionY / 2), extrusionX, extrusionY, 50, 50);");
+		settings.setPlatformCalculator("var extrusionX = printImage.getWidth();\nvar extrusionY = printImage.getHeight();\nplatformGraphics.fillRoundRect(centerX - (extrusionX / 2), centerY - (extrusionY / 2), extrusionX, extrusionY, 50, 50);");
 		settings.setExtrusionHeightMM(1.5);
 		settings.setPlatformHeightMM(1.5);
 		settings.setEdgeDetectionDisabled(false);
diff --git a/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java b/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java
index e6636b2ce..0d7e61a14 100644
--- a/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java
+++ b/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java
@@ -992,7 +992,7 @@ public double getWidthPixels() {
 	}
 	
 	public double getHeightPixels() {
-		return stlFile.getHeight() * pixelsPerMMX;
+		return stlFile.getHeight() * pixelsPerMMY;
 	}
 	
 	public int getZMinIndex() {

From 77eaa45fe78f6f3009f52d5177bd39be3554bee1 Mon Sep 17 00:00:00 2001
From: wgilster <wesgilster@gmail.com>
Date: Sat, 15 Oct 2016 20:27:55 -0500
Subject: [PATCH 2/2] Fixed zslicer point reference

---
 .../src/main/java/org/area515/resinprinter/slice/ZSlicer.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java b/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java
index 0d7e61a14..8126be638 100644
--- a/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java
+++ b/host/src/main/java/org/area515/resinprinter/slice/ZSlicer.java
@@ -478,9 +478,9 @@ public void debugPaintSlice(Graphics2D g) {
 					  g.setColor(Color.magenta);
 					  Point3d point = (Point3d)shape;
 					  g.drawLine((int)(point.x / (precisionScaler) * pixelsPerMMX + imageOffsetX), 
-							  (int)(point.y / (precisionScaler) * pixelsPerMMY + imageOffsetX), 
+							  (int)(point.y / (precisionScaler) * pixelsPerMMY + imageOffsetY), 
 							  (int)(point.x / (precisionScaler) * pixelsPerMMX + imageOffsetX), 
-							  (int)(point.y / (precisionScaler) * pixelsPerMMY + imageOffsetX));
+							  (int)(point.y / (precisionScaler) * pixelsPerMMY + imageOffsetY));
 				  } else {
 					  logger.debug("No intersection. WRONG!!!");
 				  }