From e9c3edef0f6fd73335f59b33bd271488a9930cc5 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilbu@DESKTOP-SBHQII6.(none)>
Date: Mon, 1 Aug 2016 01:25:04 -0700
Subject: [PATCH 01/15] Add photonic3d.js and test retrieving config values and
 initializing them

---
 index.html       |  1 +
 js/main.js       |  2 +-
 js/photonic3d.js | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 js/photonic3d.js

diff --git a/index.html b/index.html
index 2c57951..2640e3d 100644
--- a/index.html
+++ b/index.html
@@ -359,5 +359,6 @@ <h3 class="panel-title">Colors</h3>
         <script src="vendor/FileSaver.min.js" type="text/javascript"></script>
         <script src="vendor/jszip.min.js" type="text/javascript"></script>
         <script src="js/main.js" type="text/javascript"></script>
+        <script src="js/photonic3d.js" type="text/javascript"></script>
     </body>
 </html>
diff --git a/js/main.js b/js/main.js
index ecd6b3f..40009e8 100644
--- a/js/main.js
+++ b/js/main.js
@@ -514,7 +514,7 @@ function updateSlicerSettings() {
 
     getSlice($sliderInput.slider('getValue'));
 
-    updateSliderUI();
+    updateSlicerUI();
 }
 
 function flipGeometry() {
diff --git a/js/photonic3d.js b/js/photonic3d.js
new file mode 100644
index 0000000..e847b2c
--- /dev/null
+++ b/js/photonic3d.js
@@ -0,0 +1,43 @@
+// Photonic3D Modifications and Features to SLAcer
+
+// Utils
+function findPythagoreanC(a, b) {
+	return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
+}
+
+function setPrinterCallibrationSettings(printer) {
+	// console.log(printer);
+	var slicingProfile = printer.configuration.slicingProfile;
+	var monitorDriverConfig = printer.configuration.machineConfig.MonitorDriverConfig;
+	var dotsPermmXYAverage = (slicingProfile.DotsPermmX + slicingProfile.DotsPermmY) / 2;
+	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
+	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
+
+	var diagonalMM = diagonalNumPixels / dotsPermmDiagonal;
+	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
+	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
+
+	// $buildVolumeX.val(buildVolXmm);
+	// $buildVolumeY.val(buildVolYmm);
+	// updateBuildVolumeSettings();
+
+	// $('#screen-diagonal-unit-in').prop('checked', false);
+	// $('#screen-diagonal-unit-mm').prop('checked', true);
+	// $screenDiagonalSize.val(diagonalMM);
+
+}
+
+// Initialize values
+function intializeValues() {
+	$slicerSpeedYes[0].checked = true;
+	$slicerSpeedNo[0].checked = false;
+	updateSlicerSettings();
+
+	var printer = $.get( "/services/printers/getFirstAvailablePrinter", function( data ) {
+		if (data !== null && data !== undefined) {
+			setPrinterCallibrationSettings(data);
+		}
+	});
+}
+
+intializeValues();

From 2acf3f25ceab46e77da9a00896e4baebaa806473 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilbu@DESKTOP-SBHQII6.(none)>
Date: Wed, 3 Aug 2016 17:27:16 -0700
Subject: [PATCH 02/15] Load default STL file and fix geometry error
 temporarily

---
 js/main.js       |  5 +++--
 js/photonic3d.js | 18 ++++++++++--------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/js/main.js b/js/main.js
index 40009e8..833ea1d 100644
--- a/js/main.js
+++ b/js/main.js
@@ -695,7 +695,7 @@ function updateBuildVolumeSettings() {
     });
 
     viewer3d.setBuildVolume(settings.get('buildVolume'));
-    viewer3d.dropObject(slicer.mesh);
+    slicer.mesh && viewer3d.dropObject(slicer.mesh);
     viewer3d.render();
 
     size && updateMeshInfoUI();
@@ -1046,7 +1046,8 @@ var stl = 'stl/StressTest.stl';
 //var stl = 'stl/SLAcer.stl';
 
 // File url
-var url = 'http://' + window.location.hostname + window.location.pathname + stl;
+// var url = 'http://' + window.location.hostname + window.location.pathname + stl;
+var url = window.location.href + stl;
 
 // Create http request object
 var xmlhttp = new XMLHttpRequest();
diff --git a/js/photonic3d.js b/js/photonic3d.js
index e847b2c..14a3948 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -17,18 +17,18 @@ function setPrinterCallibrationSettings(printer) {
 	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
 	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
 
-	// $buildVolumeX.val(buildVolXmm);
-	// $buildVolumeY.val(buildVolYmm);
-	// updateBuildVolumeSettings();
+	$buildVolumeX.val(buildVolXmm);
+	$buildVolumeY.val(buildVolYmm);
+	updateBuildVolumeSettings();
 
-	// $('#screen-diagonal-unit-in').prop('checked', false);
-	// $('#screen-diagonal-unit-mm').prop('checked', true);
-	// $screenDiagonalSize.val(diagonalMM);
+	$('#screen-diagonal-unit-in').prop('checked', false);
+	$('#screen-diagonal-unit-mm').prop('checked', true);
+	$screenDiagonalSize.val(diagonalMM);
 
 }
 
 // Initialize values
-function intializeValues() {
+function initializeValues() {
 	$slicerSpeedYes[0].checked = true;
 	$slicerSpeedNo[0].checked = false;
 	updateSlicerSettings();
@@ -40,4 +40,6 @@ function intializeValues() {
 	});
 }
 
-intializeValues();
+$(window).bind('load', initializeValues);
+// $(document).ready(initializeValues);
+// initializeValues();

From a66c4b8f6d8be96ee80197b8f65f69e693514487 Mon Sep 17 00:00:00 2001
From: Angela Ko <ako926@berkeley.edu>
Date: Thu, 4 Aug 2016 14:05:27 -0700
Subject: [PATCH 03/15] Hide slicer on default and added error

---
 js/photonic3d.js | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index 14a3948..f6ced17 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -9,10 +9,14 @@ function setPrinterCallibrationSettings(printer) {
 	// console.log(printer);
 	var slicingProfile = printer.configuration.slicingProfile;
 	var monitorDriverConfig = printer.configuration.machineConfig.MonitorDriverConfig;
-	var dotsPermmXYAverage = (slicingProfile.DotsPermmX + slicingProfile.DotsPermmY) / 2;
+	var dotsPermmX = slicingProfile.DotsPermmX;
+	var dotsPermmY = slicingProfile.DotsPermmY;
+	var dotsPermmXYAverage = (dotsPermmX + dotsPermmY) / 2;
+	if (Math.abs(dotsPermmX - dotsrPermmY) >= 0.1) {
+		return true;
+	}
 	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
 	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
-
 	var diagonalMM = diagonalNumPixels / dotsPermmDiagonal;
 	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
 	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
@@ -24,20 +28,28 @@ function setPrinterCallibrationSettings(printer) {
 	$('#screen-diagonal-unit-in').prop('checked', false);
 	$('#screen-diagonal-unit-mm').prop('checked', true);
 	$screenDiagonalSize.val(diagonalMM);
-
+	return false;
 }
 
 // Initialize values
 function initializeValues() {
 	$slicerSpeedYes[0].checked = true;
 	$slicerSpeedNo[0].checked = false;
-	updateSlicerSettings();
+	$slicerSpeedDelay.val = 0;
+	$settings.set('#slicer.panel.collapsed', true);
+	$slicerBody.collapse('hide');
 
+	updateSlicerSettings();
+	var XYerr = false;
 	var printer = $.get( "/services/printers/getFirstAvailablePrinter", function( data ) {
 		if (data !== null && data !== undefined) {
-			setPrinterCallibrationSettings(data);
+			XYerr = setPrinterCallibrationSettings(data);
 		}
 	});
+
+	if (XYerr) {
+		//error 
+	}
 }
 
 $(window).bind('load', initializeValues);

From cedb31063ca4f15d1b5919e59090814320499797 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 14:16:29 -0700
Subject: [PATCH 04/15] Change way of presetting callibration settings

---
 js/main.js       |  4 +++-
 js/photonic3d.js | 27 +++++++++++++++++++++------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/js/main.js b/js/main.js
index 833ea1d..25268b0 100644
--- a/js/main.js
+++ b/js/main.js
@@ -695,7 +695,7 @@ function updateBuildVolumeSettings() {
     });
 
     viewer3d.setBuildVolume(settings.get('buildVolume'));
-    slicer.mesh && viewer3d.dropObject(slicer.mesh);
+    viewer3d.dropObject(slicer.mesh);
     viewer3d.render();
 
     size && updateMeshInfoUI();
@@ -1066,3 +1066,5 @@ xmlhttp.onreadystatechange = function() {
 }
 
 xmlhttp.send();
+
+
diff --git a/js/photonic3d.js b/js/photonic3d.js
index 14a3948..9954950 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -17,14 +17,29 @@ function setPrinterCallibrationSettings(printer) {
 	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
 	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
 
-	$buildVolumeX.val(buildVolXmm);
-	$buildVolumeY.val(buildVolYmm);
-	updateBuildVolumeSettings();
+	// $buildVolumeX.val(buildVolXmm);
+	// $buildVolumeY.val(buildVolYmm);
+	// updateBuildVolumeSettings();
+    
+    var unit = $('#build-volume input[type=radio]:checked').val();
+
+    settings.set('buildVolume', {
+        size: {
+            x: buildVolXmm,
+            y: buildVolYmm,
+            z: $buildVolumeZ.val()
+        },
+        unit: unit
+    });
+    viewer3d.setBuildVolume(settings.get('buildVolume'));
+    updateBuildVolumeUI();
+
 
 	$('#screen-diagonal-unit-in').prop('checked', false);
 	$('#screen-diagonal-unit-mm').prop('checked', true);
 	$screenDiagonalSize.val(diagonalMM);
 
+	updateScreenSettings();
 }
 
 // Initialize values
@@ -40,6 +55,6 @@ function initializeValues() {
 	});
 }
 
-$(window).bind('load', initializeValues);
-// $(document).ready(initializeValues);
-// initializeValues();
+// $(window).bind('load', initializeValues);
+$(document).ready(initializeValues);
+// initializeValues();
\ No newline at end of file

From 9b7ef81ed47cbb71e5f5a9339eb2f40842f31894 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 14:51:17 -0700
Subject: [PATCH 05/15] Revert

---
 index.html       |  1 -
 js/main.js       |  2 +-
 js/photonic3d.js | 76 ------------------------------------------------
 3 files changed, 1 insertion(+), 78 deletions(-)
 delete mode 100644 js/photonic3d.js

diff --git a/index.html b/index.html
index 2640e3d..2c57951 100644
--- a/index.html
+++ b/index.html
@@ -359,6 +359,5 @@ <h3 class="panel-title">Colors</h3>
         <script src="vendor/FileSaver.min.js" type="text/javascript"></script>
         <script src="vendor/jszip.min.js" type="text/javascript"></script>
         <script src="js/main.js" type="text/javascript"></script>
-        <script src="js/photonic3d.js" type="text/javascript"></script>
     </body>
 </html>
diff --git a/js/main.js b/js/main.js
index 25268b0..ec91577 100644
--- a/js/main.js
+++ b/js/main.js
@@ -514,7 +514,7 @@ function updateSlicerSettings() {
 
     getSlice($sliderInput.slider('getValue'));
 
-    updateSlicerUI();
+    updateSliderUI();
 }
 
 function flipGeometry() {
diff --git a/js/photonic3d.js b/js/photonic3d.js
deleted file mode 100644
index 899e26e..0000000
--- a/js/photonic3d.js
+++ /dev/null
@@ -1,76 +0,0 @@
-// Photonic3D Modifications and Features to SLAcer
-
-// Utils
-function findPythagoreanC(a, b) {
-	return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
-}
-
-function setPrinterCallibrationSettings(printer) {
-	// console.log(printer);
-	var slicingProfile = printer.configuration.slicingProfile;
-	var monitorDriverConfig = printer.configuration.machineConfig.MonitorDriverConfig;
-	var dotsPermmX = slicingProfile.DotsPermmX;
-	var dotsPermmY = slicingProfile.DotsPermmY;
-	var dotsPermmXYAverage = (dotsPermmX + dotsPermmY) / 2;
-	if (Math.abs(dotsPermmX - dotsrPermmY) >= 0.1) {
-		return true;
-	}
-	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
-	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
-	var diagonalMM = diagonalNumPixels / dotsPermmDiagonal;
-	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
-	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
-
-	// $buildVolumeX.val(buildVolXmm);
-	// $buildVolumeY.val(buildVolYmm);
-	// updateBuildVolumeSettings();
-    
-    /* This is part of updateBuildVolumeSettings() from main.js. I only copied
-    the necessary code that won't result in geometry error */
-    var unit = $('#build-volume input[type=radio]:checked').val();
-
-    settings.set('buildVolume', {
-        size: {
-            x: buildVolXmm,
-            y: buildVolYmm,
-            z: $buildVolumeZ.val()
-        },
-        unit: unit
-    });
-    viewer3d.setBuildVolume(settings.get('buildVolume'));
-    updateBuildVolumeUI();
-
-
-	$('#screen-diagonal-unit-in').prop('checked', false);
-	$('#screen-diagonal-unit-mm').prop('checked', true);
-	$screenDiagonalSize.val(diagonalMM);
-	updateScreenSettings();
-
-	// No error occurred so return false
-	return false;
-}
-
-// Initialize values
-function initializeValues() {
-	$slicerSpeedYes[0].checked = true;
-	$slicerSpeedNo[0].checked = false;
-	$slicerSpeedDelay.val = 0;
-	$settings.set('#slicer.panel.collapsed', true);
-	$slicerBody.collapse('hide');
-
-	updateSlicerSettings();
-	var XYerr = false;
-	var printer = $.get( "/services/printers/getFirstAvailablePrinter", function( data ) {
-		if (data !== null && data !== undefined) {
-			XYerr = setPrinterCallibrationSettings(data);
-		}
-	});
-
-	if (XYerr) {
-		// Error handling
-	}
-}
-
-// $(window).bind('load', initializeValues);
-$(document).ready(initializeValues);
-// initializeValues();
\ No newline at end of file

From a9bba43b13df6a5cbe0e6dc6770f0dee06964d5a Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 14:58:23 -0700
Subject: [PATCH 06/15] Change url in load example to relative url

---
 js/main.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/main.js b/js/main.js
index ec91577..93b3991 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1045,7 +1045,7 @@ loader.onError = errorHandler;
 var stl = 'stl/StressTest.stl';
 //var stl = 'stl/SLAcer.stl';
 
-// File url
+// File url 
 // var url = 'http://' + window.location.hostname + window.location.pathname + stl;
 var url = window.location.href + stl;
 

From 36836fa717ce763cd2557eb4a69072cee9b2c240 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 15:00:16 -0700
Subject: [PATCH 07/15] Add photonic3d.js script in html

---
 index.html | 1 +
 js/main.js | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/index.html b/index.html
index 2c57951..2640e3d 100644
--- a/index.html
+++ b/index.html
@@ -359,5 +359,6 @@ <h3 class="panel-title">Colors</h3>
         <script src="vendor/FileSaver.min.js" type="text/javascript"></script>
         <script src="vendor/jszip.min.js" type="text/javascript"></script>
         <script src="js/main.js" type="text/javascript"></script>
+        <script src="js/photonic3d.js" type="text/javascript"></script>
     </body>
 </html>
diff --git a/js/main.js b/js/main.js
index 93b3991..ec91577 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1045,7 +1045,7 @@ loader.onError = errorHandler;
 var stl = 'stl/StressTest.stl';
 //var stl = 'stl/SLAcer.stl';
 
-// File url 
+// File url
 // var url = 'http://' + window.location.hostname + window.location.pathname + stl;
 var url = window.location.href + stl;
 

From 9d8c73d375ea7db5ea57d2864870b60b2a176874 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 15:00:53 -0700
Subject: [PATCH 08/15] Set callibration settings in SLAcer and fix geometry
 error

---
 js/photonic3d.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
 create mode 100644 js/photonic3d.js

diff --git a/js/photonic3d.js b/js/photonic3d.js
new file mode 100644
index 0000000..899e26e
--- /dev/null
+++ b/js/photonic3d.js
@@ -0,0 +1,76 @@
+// Photonic3D Modifications and Features to SLAcer
+
+// Utils
+function findPythagoreanC(a, b) {
+	return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
+}
+
+function setPrinterCallibrationSettings(printer) {
+	// console.log(printer);
+	var slicingProfile = printer.configuration.slicingProfile;
+	var monitorDriverConfig = printer.configuration.machineConfig.MonitorDriverConfig;
+	var dotsPermmX = slicingProfile.DotsPermmX;
+	var dotsPermmY = slicingProfile.DotsPermmY;
+	var dotsPermmXYAverage = (dotsPermmX + dotsPermmY) / 2;
+	if (Math.abs(dotsPermmX - dotsrPermmY) >= 0.1) {
+		return true;
+	}
+	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
+	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
+	var diagonalMM = diagonalNumPixels / dotsPermmDiagonal;
+	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
+	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
+
+	// $buildVolumeX.val(buildVolXmm);
+	// $buildVolumeY.val(buildVolYmm);
+	// updateBuildVolumeSettings();
+    
+    /* This is part of updateBuildVolumeSettings() from main.js. I only copied
+    the necessary code that won't result in geometry error */
+    var unit = $('#build-volume input[type=radio]:checked').val();
+
+    settings.set('buildVolume', {
+        size: {
+            x: buildVolXmm,
+            y: buildVolYmm,
+            z: $buildVolumeZ.val()
+        },
+        unit: unit
+    });
+    viewer3d.setBuildVolume(settings.get('buildVolume'));
+    updateBuildVolumeUI();
+
+
+	$('#screen-diagonal-unit-in').prop('checked', false);
+	$('#screen-diagonal-unit-mm').prop('checked', true);
+	$screenDiagonalSize.val(diagonalMM);
+	updateScreenSettings();
+
+	// No error occurred so return false
+	return false;
+}
+
+// Initialize values
+function initializeValues() {
+	$slicerSpeedYes[0].checked = true;
+	$slicerSpeedNo[0].checked = false;
+	$slicerSpeedDelay.val = 0;
+	$settings.set('#slicer.panel.collapsed', true);
+	$slicerBody.collapse('hide');
+
+	updateSlicerSettings();
+	var XYerr = false;
+	var printer = $.get( "/services/printers/getFirstAvailablePrinter", function( data ) {
+		if (data !== null && data !== undefined) {
+			XYerr = setPrinterCallibrationSettings(data);
+		}
+	});
+
+	if (XYerr) {
+		// Error handling
+	}
+}
+
+// $(window).bind('load', initializeValues);
+$(document).ready(initializeValues);
+// initializeValues();
\ No newline at end of file

From a9a57cc0deb436154725308b9930336b9ae2566f Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 15:17:41 -0700
Subject: [PATCH 09/15] Change url in load example to relative url

---
 js/main.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/js/main.js b/js/main.js
index ecd6b3f..a6f9b1d 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1046,8 +1046,8 @@ var stl = 'stl/StressTest.stl';
 //var stl = 'stl/SLAcer.stl';
 
 // File url
-var url = 'http://' + window.location.hostname + window.location.pathname + stl;
-
+// var url = 'http://' + window.location.hostname + window.location.pathname + stl;
+var url = window.location.href + stl;
 // Create http request object
 var xmlhttp = new XMLHttpRequest();
 

From d5aaa40f6349670cab874162c28d87f90e53203a Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 15:19:30 -0700
Subject: [PATCH 10/15] Add photonic3d.js in html

---
 index.html | 1 +
 js/main.js | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/index.html b/index.html
index 2c57951..2640e3d 100644
--- a/index.html
+++ b/index.html
@@ -359,5 +359,6 @@ <h3 class="panel-title">Colors</h3>
         <script src="vendor/FileSaver.min.js" type="text/javascript"></script>
         <script src="vendor/jszip.min.js" type="text/javascript"></script>
         <script src="js/main.js" type="text/javascript"></script>
+        <script src="js/photonic3d.js" type="text/javascript"></script>
     </body>
 </html>
diff --git a/js/main.js b/js/main.js
index a6f9b1d..ec91577 100644
--- a/js/main.js
+++ b/js/main.js
@@ -1048,6 +1048,7 @@ var stl = 'stl/StressTest.stl';
 // File url
 // var url = 'http://' + window.location.hostname + window.location.pathname + stl;
 var url = window.location.href + stl;
+
 // Create http request object
 var xmlhttp = new XMLHttpRequest();
 
@@ -1065,3 +1066,5 @@ xmlhttp.onreadystatechange = function() {
 }
 
 xmlhttp.send();
+
+

From a457026a3be073388404d2e8f9172ac35c8feef8 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 15:19:50 -0700
Subject: [PATCH 11/15] Create photonic3d.js and set callibration settings in
 UI

---
 js/photonic3d.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 js/photonic3d.js

diff --git a/js/photonic3d.js b/js/photonic3d.js
new file mode 100644
index 0000000..10f6433
--- /dev/null
+++ b/js/photonic3d.js
@@ -0,0 +1,74 @@
+// Photonic3D Modifications and Features to SLAcer
+
+// Utils
+function findPythagoreanC(a, b) {
+	return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
+}
+
+function setPrinterCallibrationSettings(printer) {
+	// console.log(printer);
+	var slicingProfile = printer.configuration.slicingProfile;
+	var monitorDriverConfig = printer.configuration.machineConfig.MonitorDriverConfig;
+	var dotsPermmX = slicingProfile.DotsPermmX;
+	var dotsPermmY = slicingProfile.DotsPermmY;
+	var dotsPermmXYAverage = (dotsPermmX + dotsPermmY) / 2;
+	if (Math.abs(dotsPermmX - dotsrPermmY) >= 0.1) {
+		return true;
+	}
+	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
+	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
+	var diagonalMM = diagonalNumPixels / dotsPermmDiagonal;
+	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
+	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
+
+	// $buildVolumeX.val(buildVolXmm);
+	// $buildVolumeY.val(buildVolYmm);
+	// updateBuildVolumeSettings();
+    
+    /* This is part of updateBuildVolumeSettings() from main.js. I only copied
+    the necessary code that won't result in geometry error */
+    var unit = $('#build-volume input[type=radio]:checked').val();
+
+    settings.set('buildVolume', {
+        size: {
+            x: buildVolXmm,
+            y: buildVolYmm,
+            z: $buildVolumeZ.val()
+        },
+        unit: unit
+    });
+    viewer3d.setBuildVolume(settings.get('buildVolume'));
+    updateBuildVolumeUI();
+
+
+	$('#screen-diagonal-unit-in').prop('checked', false);
+	$('#screen-diagonal-unit-mm').prop('checked', true);
+	$screenDiagonalSize.val(diagonalMM);
+	updateScreenSettings();
+
+	// No error occurred so return false
+	return false;
+}
+
+// Initialize values
+function initializeValues() {
+	$slicerSpeedYes[0].checked = true;
+	$slicerSpeedNo[0].checked = false;
+	$slicerSpeedDelay.val = 0;
+	$settings.set('#slicer.panel.collapsed', true);
+	$slicerBody.collapse('hide');
+
+	updateSlicerSettings();
+	var XYerr = false;
+	var printer = $.get( "/services/printers/getFirstAvailablePrinter", function( data ) {
+		if (data !== null && data !== undefined) {
+			XYerr = setPrinterCallibrationSettings(data);
+		}
+	});
+
+	if (XYerr) {
+		// Error handling
+	}
+}
+
+$(document).ready(initializeValues);
\ No newline at end of file

From f7ce996341fd9489c238ab60080bf5646e786b64 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilburshi@sbcglobal.net>
Date: Thu, 4 Aug 2016 21:29:33 -0700
Subject: [PATCH 12/15] Set calibration settings by simulating manually
 inputting values on webpage

---
 js/photonic3d.js | 46 ++++++++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index c983df2..8105dda 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -5,45 +5,51 @@ function findPythagoreanC(a, b) {
 	return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
 }
 
-function setPrinterCallibrationSettings(printer) {
-	// console.log(printer);
+function setPrinterCalibrationSettings(printer) {
 	var slicingProfile = printer.configuration.slicingProfile;
 	var monitorDriverConfig = printer.configuration.machineConfig.MonitorDriverConfig;
 	var dotsPermmX = slicingProfile.DotsPermmX;
 	var dotsPermmY = slicingProfile.DotsPermmY;
 	var dotsPermmXYAverage = (dotsPermmX + dotsPermmY) / 2;
-	if (Math.abs(dotsPermmX - dotsrPermmY) >= 0.1) {
-		return true;
-	}
+	// if (Math.abs(dotsPermmX - dotsPermmY) >= 0.1) {
+	// 	return true;
+	// }
 	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
 	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
-	var diagonalMM = diagonalNumPixels / dotsPermmDiagonal;
+	var diagonalMM = Math.round(diagonalNumPixels / dotsPermmDiagonal);
 	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
 	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
 
-	// $buildVolumeX.val(buildVolXmm);
-	// $buildVolumeY.val(buildVolYmm);
-	// updateBuildVolumeSettings();
-    
     /* This is part of updateBuildVolumeSettings() from main.js. I only copied
     the necessary code that won't result in geometry error */
-    var unit = $('#build-volume input[type=radio]:checked').val();
-
     settings.set('buildVolume', {
         size: {
             x: buildVolXmm,
             y: buildVolYmm,
             z: $buildVolumeZ.val()
         },
-        unit: unit
+        unit: 'mm'
     });
     viewer3d.setBuildVolume(settings.get('buildVolume'));
+    viewer3d.render();
     updateBuildVolumeUI();
 
 
 	$('#screen-diagonal-unit-in').prop('checked', false);
 	$('#screen-diagonal-unit-mm').prop('checked', true);
-	$screenDiagonalSize.val(diagonalMM);
+	
+	// After manually checking the mm unit, set the values then update UI
+ //    settings.set('screen', {
+ //        width   : $screenWidth.val(),
+ //        height  : $screenHeight.val(),
+ //        diagonal: {
+ //            size: diagonalMM,
+ //            unit: 'mm'
+ //        }
+ //    });
+	// updateScreenUI();
+
+	$screenDiagonalSize.val(100);
 	updateScreenSettings();
 
 	// No error occurred so return false
@@ -54,15 +60,19 @@ function setPrinterCallibrationSettings(printer) {
 function initializeValues() {
 	$slicerSpeedYes[0].checked = true;
 	$slicerSpeedNo[0].checked = false;
-	$slicerSpeedDelay.val = 0;
-	$settings.set('#slicer.panel.collapsed', true);
+	$slicerSpeedDelay.val(0);
+
+	// Update global javascript object with slicer settings
+    settings.set('slicer.speed', $slicerSpeedYes[0].checked);
+    settings.set('slicer.speedDelay', $slicerSpeedDelay.val());
+	
+	settings.set('#slicer.panel.collapsed', true);
 	$slicerBody.collapse('hide');
 
-	updateSlicerSettings();
 	var XYerr = false;
 	var printer = $.get( "/services/printers/getFirstAvailablePrinter", function( data ) {
 		if (data !== null && data !== undefined) {
-			XYerr = setPrinterCallibrationSettings(data);
+			XYerr = setPrinterCalibrationSettings(data);
 		}
 	});
 

From 381b7a18c8b16b7796f01d9876f7e5470028105c Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilbu@DESKTOP-SBHQII6.(none)>
Date: Fri, 5 Aug 2016 00:51:54 -0700
Subject: [PATCH 13/15] Change hardcoded diagonalmm value

---
 js/photonic3d.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index 8105dda..326454c 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -49,7 +49,7 @@ function setPrinterCalibrationSettings(printer) {
  //    });
 	// updateScreenUI();
 
-	$screenDiagonalSize.val(100);
+	$screenDiagonalSize.val(diagonalMM);
 	updateScreenSettings();
 
 	// No error occurred so return false

From 065be2b314056c29618ba303bf6924dcf5be74f4 Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilbu@DESKTOP-SBHQII6.(none)>
Date: Fri, 5 Aug 2016 16:41:39 -0700
Subject: [PATCH 14/15] Add null check for viewer3d.dropObject

---
 js/main.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/js/main.js b/js/main.js
index ec91577..7663611 100644
--- a/js/main.js
+++ b/js/main.js
@@ -695,7 +695,7 @@ function updateBuildVolumeSettings() {
     });
 
     viewer3d.setBuildVolume(settings.get('buildVolume'));
-    viewer3d.dropObject(slicer.mesh);
+    slicer.mesh && viewer3d.dropObject(slicer.mesh);
     viewer3d.render();
 
     size && updateMeshInfoUI();

From 1bd122b2b1f089e7ae596a9fea3ec8a1c34cbd4c Mon Sep 17 00:00:00 2001
From: Wilbur Shi <wilbu@DESKTOP-SBHQII6.(none)>
Date: Fri, 5 Aug 2016 16:48:22 -0700
Subject: [PATCH 15/15] Fix build volume settings

---
 js/photonic3d.js | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/js/photonic3d.js b/js/photonic3d.js
index 326454c..e6a1907 100644
--- a/js/photonic3d.js
+++ b/js/photonic3d.js
@@ -14,41 +14,22 @@ function setPrinterCalibrationSettings(printer) {
 	// if (Math.abs(dotsPermmX - dotsPermmY) >= 0.1) {
 	// 	return true;
 	// }
-	var dotsPermmDiagonal = findPythagoreanC(dotsPermmXYAverage, dotsPermmXYAverage);
-	var diagonalNumPixels = findPythagoreanC(monitorDriverConfig.DLP_X_Res, monitorDriverConfig.DLP_Y_Res);
-	var diagonalMM = Math.round(diagonalNumPixels / dotsPermmDiagonal);
 	var buildVolXmm = Math.round(monitorDriverConfig.DLP_X_Res / dotsPermmXYAverage);
 	var buildVolYmm = Math.round(monitorDriverConfig.DLP_Y_Res / dotsPermmXYAverage);
+	var diagonalMM = Math.round(findPythagoreanC(buildVolXmm, buildVolYmm));
 
     /* This is part of updateBuildVolumeSettings() from main.js. I only copied
     the necessary code that won't result in geometry error */
-    settings.set('buildVolume', {
-        size: {
-            x: buildVolXmm,
-            y: buildVolYmm,
-            z: $buildVolumeZ.val()
-        },
-        unit: 'mm'
-    });
-    viewer3d.setBuildVolume(settings.get('buildVolume'));
-    viewer3d.render();
-    updateBuildVolumeUI();
+    $buildVolumeX.val(buildVolXmm);
+    $buildVolumeY.val(buildVolYmm);
+    $buildVolumeZ.val(printer.configuration.machineConfig.PlatformZSize);
+    updateBuildVolumeSettings();
 
 
 	$('#screen-diagonal-unit-in').prop('checked', false);
 	$('#screen-diagonal-unit-mm').prop('checked', true);
 	
 	// After manually checking the mm unit, set the values then update UI
- //    settings.set('screen', {
- //        width   : $screenWidth.val(),
- //        height  : $screenHeight.val(),
- //        diagonal: {
- //            size: diagonalMM,
- //            unit: 'mm'
- //        }
- //    });
-	// updateScreenUI();
-
 	$screenDiagonalSize.val(diagonalMM);
 	updateScreenSettings();
 
@@ -79,6 +60,8 @@ function initializeValues() {
 	if (XYerr) {
 		// Error handling
 	}
+
+	// loader.load(/*insert file here*/);
 }
 
 $(document).ready(initializeValues);
