+
+
+
+
+
diff --git a/host/resourcesnew/cwh/js/copySlicingProfile.js b/host/resourcesnew/cwh/js/copySlicingProfile.js
new file mode 100644
index 000000000..3dbef0a69
--- /dev/null
+++ b/host/resourcesnew/cwh/js/copySlicingProfile.js
@@ -0,0 +1,17 @@
+(function() {
+ var cwhApp = angular.module('cwhApp');
+
+ cwhApp.controller("copySLicingProfileController", function ($scope, $uibModalInstance, title, sliceData, nameProfile) {
+ $scope.title = title;
+ $scope.sliceData = sliceData;
+ $scope.save = function () {
+ $uibModalInstance.close(sliceData);
+ };
+
+ $scope.cancel = function () {
+ $uibModalInstance.dismiss('cancel');
+ };
+
+ })
+
+})();
diff --git a/host/resourcesnew/cwh/js/editMessage.js b/host/resourcesnew/cwh/js/editMessage.js
new file mode 100644
index 000000000..8188d0a04
--- /dev/null
+++ b/host/resourcesnew/cwh/js/editMessage.js
@@ -0,0 +1,18 @@
+(function() {
+ var cwhApp = angular.module('cwhApp');
+
+ cwhApp.controller("EditMessageController", function ($scope, $http, $uibModalInstance, title, editMessage, users) {
+ $scope.users = users;
+ $scope.title = title;
+ $scope.editMessage = editMessage;
+
+ $scope.save = function () {
+ $uibModalInstance.close(editMessage);
+ };
+
+ $scope.cancel = function () {
+ $uibModalInstance.dismiss('cancel');
+ };
+ })
+
+})();
\ No newline at end of file
diff --git a/host/resourcesnew/cwh/js/editPrinter.js b/host/resourcesnew/cwh/js/editPrinter.js
index 8ac6f3526..9fbadea97 100644
--- a/host/resourcesnew/cwh/js/editPrinter.js
+++ b/host/resourcesnew/cwh/js/editPrinter.js
@@ -10,7 +10,8 @@
$scope.parities = ["Even", "Mark", "None", "Odd", "Space"];
$scope.stopBits = ["None", "One", "1.5", "Two"];
$scope.dataBits = [5, 6, 7, 8, 9];
-
+ $scope.fullScreenModes = ["AlwaysUseFullScreen", "NeverUseFullScreen", "UseFullScreenWhenExclusiveIsAvailable"];
+
$http.get('/services/machine/serialPorts/list').success(
function (data) {
$scope.serialPorts = data;
diff --git a/host/resourcesnew/cwh/js/editResin.js b/host/resourcesnew/cwh/js/editResin.js
new file mode 100644
index 000000000..466e1d1cd
--- /dev/null
+++ b/host/resourcesnew/cwh/js/editResin.js
@@ -0,0 +1,28 @@
+(function() {
+ var cwhApp = angular.module('cwhApp');
+
+ cwhApp.controller("EditResinController", function ($scope, $http, $uibModalInstance, title) {
+
+ // init a new resin profile
+ $scope.title = title;
+ $scope.inkConfigArr = {
+ FirstLayerTime:'',
+ LayerTime:'',
+ Name:'',
+ NumberofBottomLayers:'',
+ PercentageOfPrintMaterialConsideredEmpty:'',
+ ResinPriceL:"", SliceHeight:''
+ };
+
+ $scope.save = function () {
+ console.log($scope.inkConfigArr);
+ $uibModalInstance.close($scope.inkConfigArr);
+ };
+
+ $scope.cancel = function () {
+ $uibModalInstance.dismiss('cancel');
+ };
+
+ })
+
+})();
\ No newline at end of file
diff --git a/host/resourcesnew/cwh/js/index.js b/host/resourcesnew/cwh/js/index.js
index 4fcb3304b..8c5acd9a5 100644
--- a/host/resourcesnew/cwh/js/index.js
+++ b/host/resourcesnew/cwh/js/index.js
@@ -7,6 +7,20 @@
};
}]);
+ cwhApp.directive('onEnter', function () {
+ return function (scope, element, attrs) {
+ element.bind("keydown keypress", function (event) {
+ if(event.which === 13) {
+ scope.$apply(function (){
+ scope.$eval(attrs.onEnter);
+ });
+
+ event.preventDefault();
+ }
+ });
+ };
+ });
+
cwhApp.factory('photonicUtils', ['$http', '$rootScope', function($http, $rootScope) {
return {
previewExternalStateId:firstCacheId,
@@ -59,6 +73,9 @@
if (processorContainer.printFileProcessor.friendlyName === 'Scalable Vector Graphics') {
return "fa-puzzle-piece";
}
+ if (processorContainer.printFileProcessor.friendlyName === 'Coin') {
+ return "fa-user-circle";
+ }
return "fa-question-circle";
},
diff --git a/host/resourcesnew/cwh/js/printables.js b/host/resourcesnew/cwh/js/printables.js
index 3b167da82..c64db1640 100644
--- a/host/resourcesnew/cwh/js/printables.js
+++ b/host/resourcesnew/cwh/js/printables.js
@@ -2,7 +2,7 @@
var cwhApp = angular.module('cwhApp');
cwhApp.controller("PrintablesController", ['$scope', '$http', '$location', '$uibModal', '$anchorScroll', 'cwhWebSocket', 'photonicUtils', function ($scope, $http, $location, $uibModal, $anchorScroll, cwhWebSocket, photonicUtils) {
controller = this;
-
+
this.currentPrintable = null;
this.currentCustomizer = null;
this.currentPrinter = null;
@@ -260,7 +260,12 @@
this.writeDrainHoldCode = function writeDrainHoldCode() {
controller.currentCustomizer.imageManipulationCalculator =
- "var drainHoleInMM = { centerX:centerX, centerY:centerY, widthX:5, widthY:5, depth:5};\n\n" +
+ "var drainHoleInMM = {\n" +
+ " centerX:centerX,\n" +
+ " centerY:centerY,\n" +
+ " widthX:5,\n" +
+ " widthY:5,\n" +
+ " depth:5};\n\n" +
"if (($CURSLICE * $LayerThickness) <= drainHoleInMM.depth) {\n" +
" buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
" buildPlatformGraphics.fillOval(\n" +
@@ -273,24 +278,107 @@
controller.clearExternalCacheAndSaveCustomizer();
};
+ this.writeCenteredTextCode = function writeCenteredTextCode() {
+ controller.currentCustomizer.imageManipulationCalculator =
+ "var serial = \"123456\";\n" +
+ "var twoDFont = job.buildFont();\n" +
+ "var metrics = buildPlatformGraphics.getFontMetrics(twoDFont);\n" +
+ "buildPlatformGraphics.setFont(twoDFont);\n" +
+ "buildPlatformGraphics.setColor(java.awt.Color.WHITE);\n" +
+ "buildPlatformGraphics.drawString(serial, centerX - metrics.stringWidth(serial) / 2, centerY - metrics.getHeight() / 2 + metrics.getAscent());\n"
+
+ controller.clearExternalCacheAndSaveCustomizer();
+ };
+
this.writeDuplicationGridCode = function writeDuplicationGridCode() {
controller.currentCustomizer.imageManipulationCalculator =
- "var gridDataInMM = {distanceBetweenImagesX: 1, distanceBetweenImagesY: 1, numberOfRows:3, numberOfColumns:3 };\n\n" +
+ "var gridDataInMM = {\n" +
+ " distanceBetweenImagesX: 1,\n" +
+ " distanceBetweenImagesY: 1,\n" +
+ " numberOfRows:3,\n" +
+ " numberOfColumns:3};\n\n" +
"for (var x = 0; x < gridDataInMM.numberOfColumns; x++) {\n" +
" for (var y = 0; y < gridDataInMM.numberOfRows; y++) {\n" +
" if (x > 0 || y > 0) {\n" +
" var currentTransform = new java.awt.geom.AffineTransform(affineTransform);\n" +
" currentTransform.translate(\n" +
- " (x * gridDataInMM.distanceBetweenImagesX * pixelsPerMMX) + (x * printImage.getWidth()),\n" +
- " (y * gridDataInMM.distanceBetweenImagesY * pixelsPerMMY) + (y * printImage.getHeight()));\n" +
+ " Math.round(x * gridDataInMM.distanceBetweenImagesX * pixelsPerMMX) + (x * printableShape.getWidth()),\n" +
+ " Math.round(y * gridDataInMM.distanceBetweenImagesY * pixelsPerMMY) + (y * printableShape.getHeight()));\n" +
" buildPlatformGraphics.drawImage(printImage, currentTransform, null);\n" +
" }\n" +
" }\n" +
"}\n";
-
controller.clearExternalCacheAndSaveCustomizer();
};
+ this.writeDuplicationGridWithVariableExposureTimeCode = function writeDuplicationGridWithVariableExposureTimeCode() {
+ controller.currentCustomizer.imageManipulationCalculator =
+ "var gridDataInMM = {\n" +
+ " distanceBetweenImagesX: 1,\n" +
+ " distanceBetweenImagesY: 1,\n" +
+ " numberOfRows:3,\n" +
+ " numberOfColumns:3,\n" +
+ " exposureTimeDecrementMillis:1000};\n\n" +
+ "for (var x = 0; x < gridDataInMM.numberOfColumns; x++) {\n" +
+ " for (var y = 0; y < gridDataInMM.numberOfRows; y++) {\n" +
+ " if (x > 0 || y > 0) {\n" +
+ " var currentTransform = new java.awt.geom.AffineTransform(affineTransform);\n" +
+ " currentTransform.translate(\n" +
+ " Math.round(x * gridDataInMM.distanceBetweenImagesX * pixelsPerMMX) + (x * printableShape.getWidth()),\n" +
+ " Math.round(y * gridDataInMM.distanceBetweenImagesY * pixelsPerMMY) + (y * printableShape.getHeight()));\n" +
+ " buildPlatformGraphics.drawImage(printImage, currentTransform, null);\n" +
+ " exposureTimers.add({\n" +
+ " delayMillis:$LayerTime - ((y * gridDataInMM.numberOfColumns) + x) * gridDataInMM.exposureTimeDecrementMillis,\n" +
+ " parameter:currentTransform.createTransformedShape(printableShape),\n" +
+ " function:function(blackRect) {\n" +
+ " buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
+ " buildPlatformGraphics.fill(blackRect);\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ controller.clearExternalCacheAndSaveCustomizer();
+ };
+
+ this.writeDuplicationGridWithSerialNumber = function() {
+ controller.currentCustomizer.imageManipulationCalculator =
+ "var gridDataInMM = {\n" +
+ " distanceBetweenImagesX: 1,\n" +
+ " distanceBetweenImagesY: 1,\n" +
+ " numberOfRows:3,\n" +
+ " numberOfColumns:3,\n" +
+ " startingSerialNumber:888,\n" +
+ " serialNumberCenterXPixels: printableShape.getWidth() / 2,\n" +
+ " serialNumberCenterYPixels: printableShape.getHeight() / 2,\n" +
+ " serialNumberDepth:0.5};\n\n" +
+ "var twoDFont = job.buildFont();\n" +
+ "var metrics = buildPlatformGraphics.getFontMetrics(twoDFont);\n" +
+ "var oldTransform = buildPlatformGraphics.getTransform();\n" +
+ "buildPlatformGraphics.setFont(twoDFont);\n" +
+ "buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
+ "for (var x = 0; x < gridDataInMM.numberOfColumns; x++) {\n" +
+ " for (var y = 0; y < gridDataInMM.numberOfRows; y++) {\n" +
+ " var currentTransform = new java.awt.geom.AffineTransform(affineTransform);\n" +
+ " if (x > 0 || y > 0) {\n" +
+ " currentTransform.translate(\n" +
+ " Math.round(x * gridDataInMM.distanceBetweenImagesX * pixelsPerMMX) + (x * printableShape.getWidth()),\n" +
+ " Math.round(y * gridDataInMM.distanceBetweenImagesY * pixelsPerMMY) + (y * printableShape.getHeight()));\n" +
+ " buildPlatformGraphics.drawImage(printImage, currentTransform, null);\n" +
+ " }\n" +
+ " if (($CURSLICE * $LayerThickness) <= gridDataInMM.serialNumberDepth) {\n" +
+ " buildPlatformGraphics.setTransform(currentTransform);\n" +
+ " var nextSerialNumber = new java.lang.Integer(gridDataInMM.startingSerialNumber + (x * gridDataInMM.numberOfRows) + y).toString(16).toUpperCase();\n" +
+ " buildPlatformGraphics.drawString(nextSerialNumber, \n" +
+ " gridDataInMM.serialNumberCenterXPixels - metrics.stringWidth(nextSerialNumber) / 2, \n" +
+ " gridDataInMM.serialNumberCenterYPixels - metrics.getHeight() / 2 + metrics.getAscent());\n" +
+ " buildPlatformGraphics.setTransform(oldTransform);\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ controller.clearExternalCacheAndSaveCustomizer();
+ }
+
this.write3dTwistCode = function write3dTwistCode() {
controller.currentCustomizer.affineTransformSettings.affineTransformScriptCalculator =
"var currentTransform = new java.awt.geom.AffineTransform();\n" +
@@ -301,6 +389,30 @@
"currentTransform";
}
+ this.correctAspectRatio = function correctAspectRatio() {
+ controller.currentCustomizer.affineTransformSettings.affineTransformScriptCalculator =
+ "var currentTransform = new java.awt.geom.AffineTransform();\n" +
+ "var scaleXDimension = false;\n" +
+ "var ppmmx = pixelsPerMMX;\n" +
+ "var ppmmy = pixelsPerMMY;\n" +
+ "function reduce(numerator,denominator){\n" +
+ " var gcd = function gcd(a,b){\n" +
+ " return b ? gcd(b, a%b) : a;\n" +
+ " };\n" +
+ " gcd = gcd(numerator,denominator);\n" +
+ " return [numerator/gcd, denominator/gcd];\n" +
+ "}\n" +
+ "var reduced = reduce(ppmmx, ppmmy);" +
+ "ppmmx = reduced[0];\n" +
+ "ppmmy = reduced[1];\n" +
+ "if (scaleXDimension) {\n" +
+ " currentTransform.scale(ppmmx / ppmmy, 1);\n" +
+ "} else {\n" +
+ " currentTransform.scale(1, ppmmy / ppmmx);\n" +
+ "}\n" +
+ "currentTransform";
+ }
+
this.getPrintableIconClass = function getPrintableIconClass(printable) {
return photonicUtils.getPrintFileProcessorIconClass(printable);
};
diff --git a/host/resourcesnew/cwh/js/printerControls.js b/host/resourcesnew/cwh/js/printerControls.js
index 7ab789f65..452536b89 100644
--- a/host/resourcesnew/cwh/js/printerControls.js
+++ b/host/resourcesnew/cwh/js/printerControls.js
@@ -74,7 +74,7 @@
$http.get("services/printers/motors" + (isOn?"On":"Off") + "/" + printerName).then(gCodeSuccess, errorFunction)
}
this.executeGCode = function executeGCode() {
- $http.get("services/printers/executeGCode/" + printerName + "/" + controller.gCodeToSend).then(gCodeSuccess, errorFunction)
+ $http.get("services/printers/executeGCode/" + encodeURIComponent(printerName) + "/" + encodeURIComponent(controller.gCodeToSend)).then(gCodeSuccess, errorFunction)
}
this.projector = function projector(startStop) {
$http.get("services/printers/" + startStop + "Projector/" + printerName).then(gCodeSuccess, errorFunction)
diff --git a/host/resourcesnew/cwh/js/printers.js b/host/resourcesnew/cwh/js/printers.js
index 6d7afa1ab..bf68fd699 100644
--- a/host/resourcesnew/cwh/js/printers.js
+++ b/host/resourcesnew/cwh/js/printers.js
@@ -6,44 +6,43 @@
var BRANCH = "master";
var REPO = $scope.repo;
+ var tempSLicingProfile;
+
this.loadingFontsMessage = "--- Loading fonts from server ---"
this.loadingProfilesMessage = "--- Loading slicing profiles from server ---"
this.loadingMachineConfigMessage = "--- Loading machine configurations from server ---"
this.autodirect = $location.search().autodirect;
+ function findAPrinterThatTheUserMostLikelyWantsToWorkWith(printerList) {
+ //There is only one printer. So it's likely they want to work with this printer
+ if (printerList.length == 1) {
+ return printerList[0];
+ }
+
+ var firstStartedPrinter = null;
+ for (var i = 0; i < printerList.length; i++) {
+ //If the user has already selected a printer. It's very likely that they want to work with it...
+ if (controller.currentPrinter != null && printerList[i].configuration.name === controller.currentPrinter.configuration.name) {
+ return printerList[i];
+ }
+
+ if (firstStartedPrinter == null && printerList[i].started) {
+ firstStartedPrinter = printerList[i];
+ }
+
+ //TODO: Isn't it more likely that they want to work with a printer that is printing than one that is simply just started?
+ }
+
+ //As the name implies, this will return the first started printer. There is a decent chance they want to work with it.
+ return firstStartedPrinter;
+ }
+
//TODO: Instead of having this method we should understand how the selected printer gets out of sync and fix that
function refreshSelectedPrinterAndAutodirectIfNecessary(printerList) {
- var foundPrinter = false;
- if (printerList.length == 1 && printerList[0].started && controller.autodirect != 'disabled') {
- controller.currentPrinter = printerList[0];
- controller.gotoPrinterControls();
- foundPrinter = true;
- } else {
- var printersStarted = 0;
- var currPrinter = null;
- for (printer of printerList) {
- if (printersStarted > 1) {
- break;
- }
- if (printer.started) {
- printersStarted += 1;
- currPrinter = printer;
- }
-
- if (controller.currentPrinter != null && printer.configuration.name === controller.currentPrinter.configuration.name) {
- controller.currentPrinter = printer;
- foundPrinter = true;
- }
- }
- if (printersStarted == 1 && controller.autodirect != 'disabled') {
- controller.currentPrinter = currPrinter;
- controller.gotoPrinterControls();
- foundPrinter = true;
- }
- }
- if (!foundPrinter) {
- controller.currentPrinter = null;
- }
+ controller.currentPrinter = findAPrinterThatTheUserMostLikelyWantsToWorkWith(printerList);
+ if (controller.autodirect != 'disabled') {
+ controller.gotoPrinterControls();
+ }
}
function refreshPrinters() {
@@ -62,11 +61,12 @@
if (postTargetPrinter) {
$http.post(service, targetPrinter).then(
function(response) {
- if (shouldRefreshPrinterList) {
- refreshPrinters();
- refreshSlicingProfiles();
- refreshMachineConfigurations();
+ if (!shouldRefreshPrinterList) {
+ controller.currentPrinter = targetPrinter;
}
+ refreshPrinters();
+ refreshSlicingProfiles();
+ refreshMachineConfigurations();
},
function(response) {
$scope.$emit("HTTPError", {status:response.status, statusText:response.data});
@@ -141,7 +141,7 @@
$http.get(printer.url).success(
function (data) {
controller.editPrinter = JSON.parse(window.atob(data.content));
- $scope.savePrinter(controller.editPrinter, false);
+ $scope.savePrinter(controller.editPrinter, true);
}).error(
function (data, status, headers, config, statusText) {
$scope.$emit("HTTPError", {status:status, statusText:data});
@@ -170,6 +170,249 @@
openSavePrinterDialog(editTitle, true);
}
+ this.writePegExposureCode = function writePegExposureCode() {
+ controller.currentPrinter.configuration.slicingProfile.TwoDimensionalSettings.PlatformCalculator =
+ "var pegSettingsMM = {\n" +
+ " rows: 5,\n" +
+ " columns: 5,\n" +
+ " fontDepth: .5,\n" +
+ " fontPointSize: 42,\n" +
+ " startingOverhangDegrees: 45,\n" +
+ " degreeIncrement: 5,\n" +
+ " pegDiameter: 3,\n" +
+ " pegStandHeight: 1,\n" +
+ " pegStandWidth: 5,\n" +
+ " distanceBetweenStands: 1,\n" +
+ " exposureTimeDecrementMillis: 1000};\n\n" +
+ "var pegStandCount = pegSettingsMM.pegStandHeight / $LayerThickness;\n" +
+ "var fontCount = pegSettingsMM.fontDepth / $LayerThickness;\n" +
+ "var pegSettingsPixels = {\n" +
+ " pegDiameterX: pegSettingsMM.pegDiameter * pixelsPerMMX,\n" +
+ " pegDiameterY: pegSettingsMM.pegDiameter * pixelsPerMMY,\n" +
+ " pegStandWidthX: pegSettingsMM.pegStandWidth * pixelsPerMMX,\n" +
+ " pegStandWidthY: pegSettingsMM.pegStandWidth * pixelsPerMMY,\n" +
+ " distanceBetweenStandsX: pegSettingsMM.distanceBetweenStands * pixelsPerMMX,\n" +
+ " distanceBetweenStandsY: pegSettingsMM.distanceBetweenStands * pixelsPerMMY,\n" +
+ " pegStandDifferenceOffsetX: ((pegSettingsMM.pegStandWidth * pixelsPerMMX) - (pegSettingsMM.pegDiameter * pixelsPerMMX)) / 2,\n" +
+ " pegStandDifferenceOffsetY: ((pegSettingsMM.pegStandWidth * pixelsPerMMY) - (pegSettingsMM.pegDiameter * pixelsPerMMY)) / 2\n" +
+ "}\n" +
+ "if ($CURSLICE < pegStandCount) {\n" +
+ " for (var x = 0; x < pegSettingsMM.columns; x++) {\n" +
+ " for (var y = 0; y < pegSettingsMM.rows; y++) {\n" +
+ " var overhangAngle = pegSettingsMM.startingOverhangDegrees + y * pegSettingsMM.degreeIncrement;\n" +
+ " var startingX = x * pegSettingsPixels.pegStandWidthX + x * pegSettingsPixels.distanceBetweenStandsX;\n" +
+ " var startingY = y * pegSettingsPixels.pegStandWidthY + y * pegSettingsPixels.distanceBetweenStandsY;\n" +
+ " buildPlatformGraphics.setColor(java.awt.Color.WHITE);\n" +
+ " buildPlatformGraphics.fillRect(\n" +
+ " startingX,\n" +
+ " startingY,\n" +
+ " pegSettingsPixels.pegStandWidthX,\n" +
+ " pegSettingsPixels.pegStandWidthY);\n" +
+ " if ($CURSLICE < fontCount) {\n" +
+ " buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
+ " buildPlatformGraphics.setFont(new java.awt.Font(\"Dialog\", 0, pegSettingsMM.fontPointSize));\n" +
+ " buildPlatformGraphics.drawString(overhangAngle + \"\", startingX, startingY + pegSettingsPixels.pegStandWidthY);\n" +
+ " }\n" +
+ " exposureTimers.add({\n" +
+ " delayMillis:$LayerTime - (pegSettingsMM.exposureTimeDecrementMillis * x),\n" +
+ " parameter:{x:startingX, y:startingY, width:pegSettingsPixels.pegStandWidthX, height:pegSettingsPixels.pegStandWidthY},\n" +
+ " function:function(blackRect) {\n" +
+ " buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
+ " buildPlatformGraphics.fillRect(\n" +
+ " blackRect.x,\n" +
+ " blackRect.y,\n" +
+ " blackRect.width,\n" +
+ " blackRect.height);\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " }\n" +
+ "} else {\n" +
+ " for (var x = 0; x < pegSettingsMM.columns; x++) {\n" +
+ " for (var y = 0; y < pegSettingsMM.rows; y++) {\n" +
+ " var overhangAngle = pegSettingsMM.startingOverhangDegrees + y * pegSettingsMM.degreeIncrement;\n" +
+ " var singleOverhangIncrement = java.lang.Math.tan(java.lang.Math.toRadians(overhangAngle)) * $LayerThickness * pixelsPerMMX;\n" +
+ " var circleOffsetX = pegSettingsPixels.pegStandDifferenceOffsetX * ((x + 1) * 2 - 1) + (singleOverhangIncrement * ($CURSLICE - pegStandCount)) + (x * pegSettingsPixels.pegDiameterX) + (x * pegSettingsPixels.distanceBetweenStandsX);\n" +
+ " var circleOffsetY = pegSettingsPixels.pegStandDifferenceOffsetY * ((y + 1) * 2 - 1) + (y * pegSettingsPixels.pegDiameterY) + (y * pegSettingsPixels.distanceBetweenStandsY);\n" +
+ " buildPlatformGraphics.fillOval(\n" +
+ " circleOffsetX,\n" +
+ " circleOffsetY,\n" +
+ " pegSettingsPixels.pegDiameterX,\n" +
+ " pegSettingsPixels.pegDiameterY);\n" +
+ " exposureTimers.add({\n" +
+ " delayMillis:$LayerTime - (pegSettingsMM.exposureTimeDecrementMillis * x),\n" +
+ " parameter:{x:circleOffsetX, y:circleOffsetY, width:pegSettingsPixels.pegDiameterX, height:pegSettingsPixels.pegDiameterY},\n" +
+ " function:function(blackRect) {\n" +
+ " buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
+ " buildPlatformGraphics.fillOval(\n" +
+ " blackRect.x,\n" +
+ " blackRect.y,\n" +
+ " blackRect.width,\n" +
+ " blackRect.height);\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+ }
+
+ this.writeHBridgeCode = function writeHBridgeCode() {
+ controller.currentPrinter.configuration.slicingProfile.TwoDimensionalSettings.PlatformCalculator =
+ "var hBridgeInMM = {\n" +
+ " wallWidth:1,\n" +
+ " gapLength:4,\n" +
+ " firstGapWidth:3,\n" +
+ " numberOfGapsInRow:6,\n" +
+ " gapWidthIncrement:3,\n" +
+ " distanceBetweenRows:1,\n" +
+ " numberOfRows:5,\n" +
+ " exposureTimeDecrementMillis:1000\n" +
+ " };\n\n" +
+ "var wallWidthX = hBridgeInMM.wallWidth * pixelsPerMMX;\n" +
+ "var wallWidthY = hBridgeInMM.wallWidth * pixelsPerMMY;\n" +
+ "var gapLengthY = hBridgeInMM.gapLength * pixelsPerMMY;\n" +
+ "var lastTermOfSeries = hBridgeInMM.firstGapWidth + hBridgeInMM.gapWidthIncrement * (hBridgeInMM.numberOfGapsInRow - 1);\n" +
+ "var totalWidthX = ((hBridgeInMM.wallWidth + hBridgeInMM.wallWidth * hBridgeInMM.numberOfGapsInRow) + (hBridgeInMM.numberOfGapsInRow * (hBridgeInMM.firstGapWidth + lastTermOfSeries) / 2)) * pixelsPerMMX;\n" +
+ "var startX = centerX - totalWidthX / 2;\n" +
+ "var startY = hBridgeInMM.numberOfRows * (hBridgeInMM.gapLength * 2 + hBridgeInMM.wallWidth) + (hBridgeInMM.numberOfRows - 1) * hBridgeInMM.distanceBetweenRows;\n" +
+ "startY = centerY - startY * pixelsPerMMY / 2;\n" +
+ "var currentY = startY;\n" +
+ "buildPlatformGraphics.setColor(java.awt.Color.WHITE);\n" +
+ "for (var currentRow = 0; currentRow < hBridgeInMM.numberOfRows; currentRow++) {\n" +
+ " var currentX = startX;\n" +
+ " if ($CURSLICE < job.totalSlices) {\n" +
+ " for (var currentGap = 0; currentGap < hBridgeInMM.numberOfGapsInRow; currentGap ++) {\n" +
+ " buildPlatformGraphics.fillRect(currentX, currentY, wallWidthX, gapLengthY * 2 + wallWidthY);\n" +
+ " currentX += wallWidthX + (hBridgeInMM.firstGapWidth + (hBridgeInMM.gapWidthIncrement * currentGap)) * pixelsPerMMX;\n" +
+ " }\n" +
+ " buildPlatformGraphics.fillRect(currentX, currentY, wallWidthX, gapLengthY * 2 + wallWidthY);\n" +
+ " buildPlatformGraphics.fillRect(startX, currentY + gapLengthY, totalWidthX, wallWidthY);\n" +
+ " } else {\n" +
+ " buildPlatformGraphics.fillRect(startX, currentY, totalWidthX, gapLengthY * 2 + wallWidthY);\n" +
+ " exposureTimers.add({\n" +
+ " delayMillis:$LayerTime - (hBridgeInMM.exposureTimeDecrementMillis * currentRow),\n" +
+ " parameter:{x:startX, y:currentY, width:totalWidthX, height:gapLengthY * 2 + wallWidthY},\n" +
+ " function:function(blackRect) {\n" +
+ " buildPlatformGraphics.setColor(java.awt.Color.BLACK);\n" +
+ " buildPlatformGraphics.fillRect(blackRect.x, blackRect.y, blackRect.width, blackRect.height);\n" +
+ " }\n" +
+ " });\n" +
+ " }\n" +
+ " currentY += gapLengthY * 2 + wallWidthY + hBridgeInMM.distanceBetweenRows * pixelsPerMMY;\n" +
+ "}\n";
+ }
+
+ function createNewResinProfile(newResinProfile) {
+ // this adds the new resinprofile in the current selected slicingprofile
+ var newSlicingProfile = controller.currentPrinter.configuration.slicingProfile;
+ newSlicingProfile.InkConfig.push(newResinProfile);
+
+ // this re-uploads the changed profile
+ $http.put("services/machine/slicingProfiles", newSlicingProfile).then(
+ function (data) {
+ // for some reason this is needed when it is the currently loaded profile, otherwise it won't show after refresh
+ $http.post('/services/printers/save', controller.currentPrinter).success(
+ function () {
+ refreshSlicingProfiles();
+ $scope.$emit("MachineResponse", {machineResponse: {command:"Settings Saved!", message:"Your new resin profile has been added!.", response:true}, successFunction:null, afterErrorFunction:null});
+ }).error(
+ function (data, status, headers, config, statusText) {
+ $scope.$emit("HTTPError", {status:status, statusText:data});
+ })
+ },
+ function (error) {
+ $scope.$emit("HTTPError", {status:error.status, statusText:error.data});
+ }
+ )
+ }
+
+ this.copySlicingProfile = function copySlicingProfile(editTitle) {
+ controller.currentSlicingProfile = JSON.parse(JSON.stringify(controller.currentPrinter.configuration.slicingProfile));
+ controller.currentSlicingProfile.name = controller.currentSlicingProfile.name + " (Copy) ";
+ openCopySlicingProfileDialog(controller.currentSlicingProfile, editTitle, controller.currentSlicingProfile.name);
+ }
+
+ function SaveEditSlicingProfile(savedProfile){
+ $http.put("services/machine/slicingProfiles", savedProfile).then(
+ function (data) {
+ refreshSlicingProfiles();
+ $scope.$emit("MachineResponse", {machineResponse: {command:"Settings Saved!", message:"Your slicing profile has been copied!.", response:true}, successFunction:null, afterErrorFunction:null});
+ },
+ function (error) {
+ $scope.$emit("HTTPError", {status:error.status, statusText:error.data});
+ }
+ )
+ }
+
+ this.openSaveResinDialog = function openSaveResinDialog(editTitle) {
+ var editPrinterModal = $uibModal.open({
+ animation: true,
+ templateUrl: 'editResin.html',
+ controller: 'EditResinController',
+ size: "lg",
+ resolve: {
+ title: function () {return editTitle;},
+ editPrinter: function () {return controller.editPrinter;}
+ }
+ });
+ editPrinterModal.result.then(function (newResinProfile) {
+ createNewResinProfile(newResinProfile)
+ });
+ }
+
+ function openCopySlicingProfileDialog(data, editTitle, currentSlicingProfileName) {
+ var copySlicingProfileModal = $uibModal.open({
+ animation: true,
+ templateUrl: 'copySlicingProfile.html',
+ controller: 'copySLicingProfileController',
+ size: "lg",
+ resolve: {
+ title: function () {return editTitle;},
+ sliceData: function () {return data;},
+ nameProfile: function() {return currentSlicingProfileName;}
+ }
+ });
+ copySlicingProfileModal.result.then(function (savedProfile) {
+ SaveEditSlicingProfile(savedProfile);
+ });
+ }
+
+ this.deleteSlicingProfile = function deleteSlicingProfile(profileName, newProfile) {
+
+ var profileNameEn = encodeURIComponent(profileName);
+ $http.delete("/services/machine/slicingProfiles/" + profileNameEn).success(function (data) {
+ refreshSlicingProfiles();
+ $scope.$emit("MachineResponse", {machineResponse: {command:"Settings removed!", message:"Your slicing profile has been removed succesfully!.", response:true}, successFunction:null, afterErrorFunction:null});
+
+ }).error(
+ function (data, status, headers, config, statusText) {
+ $scope.$emit("HTTPError", {status:status, statusText:data});
+ })
+ }
+
+ this.deleteCurrentResinProfile = function deleteCurrentResinProfile(slicingProfile) {
+ // removes the selected resinprofile from the old profile
+ slicingProfile.InkConfig.splice(slicingProfile.selectedInkConfigIndex,1);
+
+ // this re-uploads the changed profile
+ $http.put("services/machine/slicingProfiles", slicingProfile).then(
+ function (data) {
+ // for some reason this is needed when it is the currently loaded profile, otherwise it won't show after refresh
+ $http.post('/services/printers/save', controller.currentPrinter).success(
+ function () {
+ refreshSlicingProfiles();
+ $scope.$emit("MachineResponse", {machineResponse: {command:"Settings Saved!", message:"Your resin profile has been removed!.", response:true}, successFunction:null, afterErrorFunction:null});
+ }).error(
+ function (data, status, headers, config, statusText) {
+ $scope.$emit("HTTPError", {status:status, statusText:data});
+ })
+ },
+ function (error) {
+ $scope.$emit("HTTPError", {status:error.status, statusText:error.data});
+ }
+ )
+ }
+
this.startCurrentPrinter = function startCurrentPrinter() {
$('#start-btn').attr('class', 'fa fa-refresh fa-spin');
executeActionAndRefreshPrinters("Start Printer", "No printer selected to start.", '/services/printers/start/', controller.currentPrinter, false, true);
@@ -190,6 +433,9 @@
}
this.gotoPrinterControls = function gotoPrinterControls() {
+ if (controller.currentPrinter == null) {
+ return;
+ }
$location.path('/printerControlsPage').search({printerName: controller.currentPrinter.configuration.name})
};
diff --git a/host/resourcesnew/cwh/js/users.js b/host/resourcesnew/cwh/js/users.js
index 3ea80b26e..7d84b1163 100644
--- a/host/resourcesnew/cwh/js/users.js
+++ b/host/resourcesnew/cwh/js/users.js
@@ -1,11 +1,28 @@
(function() {
var cwhApp = angular.module('cwhApp');
cwhApp.controller("UsersController", ['$scope', '$http', '$location', '$anchorScroll', '$uibModal', 'photonicUtils', function ($scope, $http, $location, $anchorScroll, $uibModal, photonicUtils) {
+ $scope.guid = function guid() {
+ function s4() {
+ return Math.floor((1 + Math.random()) * 0x10000)
+ .toString(16)
+ .substring(1);
+ }
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
+ s4() + '-' + s4() + s4() + s4();
+ }
+
$scope.refreshUsers = function refreshUsers() {
$http.get('/services/users/list').success(function(data) {
$scope.users = data;
});
}
+
+ $scope.refreshMessages = function refreshMessages() {
+ $http.get('/services/messages/list').success(
+ function (data) {
+ $scope.messages = data;
+ });
+ }
$scope.openSaveUserDialog = function openSaveUserDialog(editTitle, isNewUser) {
var editUserModal = $uibModal.open({
@@ -19,12 +36,31 @@
}
});
editUserModal.result.then(function (savedUser) {$scope.saveUser(savedUser, isNewUser)});
+ }
+
+ $scope.openSaveMessageDialog = function openSaveMessageDialog(editTitle, isNewUser) {
+ var editUserModal = $uibModal.open({
+ animation: true,
+ templateUrl: 'editMessage.html',
+ controller: 'EditMessageController',
+ size: "lg",
+ resolve: {
+ title: function () {return editTitle;},
+ editMessage: function () {return $scope.editMessage;},
+ users: function () {return $scope.users;}
+ }
+ });
+ editUserModal.result.then(function (savedUser) {$scope.saveMessage(savedUser, isNewUser)});
}
$scope.changeCurrentUser = function changeCurrentUser(newUser) {
$scope.currentUser = newUser;
}
+ $scope.changeCurrentMessage = function changeCurrentMessage(newMessage) {
+ $scope.currentMessage = newMessage;
+ }
+
$scope.deleteCurrentUser = function deleteCurrentUser() {
$http.delete("/services/users/" + $scope.currentUser.userId).success(function (data) {
$scope.currentUser = null;
@@ -32,6 +68,15 @@
}).error(function (data, status, headers, config, statusText) {
$scope.$emit("HTTPError", {status:status, statusText:data});
});
+ }
+
+ $scope.deleteCurrentMessage = function deleteCurrentMessage() {
+ $http.delete("/services/messages/" + $scope.currentMessage.id).success(function (data) {
+ $scope.currentMessage = null;
+ $scope.refreshMessages();
+ }).error(function (data, status, headers, config, statusText) {
+ $scope.$emit("HTTPError", {status:status, statusText:data});
+ });
}
$scope.editCurrentUser = function editCurrentUser(editTitle) {
@@ -50,6 +95,16 @@
});
}
+ $scope.saveMessage = function saveMessage(message, isNewUser) {
+ $http.put("/services/messages", message).success(function (data) {
+ $scope.refreshMessages();
+ $scope.currentMessage = data;
+ $scope.editMessage = null;
+ }).error(function (data, status, headers, config, statusText) {
+ $scope.$emit("HTTPError", {status:status, statusText:data});
+ });
+ }
+
$scope.createNewUser = function createNewUser(editTitle) {
if ($scope.currentUser == null) {
$scope.editUser = {
@@ -62,13 +117,41 @@
} else {
$scope.editUser = JSON.parse(JSON.stringify($scope.currentUser));
$scope.editUser.name = $scope.editUser.name + " (Copy)";
+ $scope.editUser.userId = null;
$scope.editUser.credential = null;
$scope.editUser.remote = false;
}
$scope.openSaveUserDialog(editTitle, true);
}
-
+
+ $scope.createNewMessage = function createNewMessage(editTitle) {
+ $scope.editMessage = {
+ fromUser: $scope.myUser,
+ message: "test message"
+ };
+
+ if ($scope.currentUser != null) {
+ $scope.editMessage.toUser = $scope.currentUser;
+ }
+
+ if ($scope.currentMessage != null) {
+ $scope.editMessage.toUser = $scope.currentMessage.fromUser;
+ }
+
+ if (editTitle == null) {
+ editTitle = "Message from " + $scope.myUser.name;
+ }
+
+ $scope.openSaveMessageDialog(editTitle, true);
+ }
+
+ //TODO: We need to add in a watch for messages with a web socket
$scope.refreshUsers();
+ $scope.refreshMessages();
+
+ $http.get('/services/users/whoAmI').success(function(data) {
+ $scope.myUser = data;
+ });
}])
})();
diff --git a/host/resourcesnew/editMessage.html b/host/resourcesnew/editMessage.html
new file mode 100644
index 000000000..aa2e93569
--- /dev/null
+++ b/host/resourcesnew/editMessage.html
@@ -0,0 +1,37 @@
+
+
+
diff --git a/host/resourcesnew/editPrinter.html b/host/resourcesnew/editPrinter.html
index 577b1777f..1ed55edd5 100644
--- a/host/resourcesnew/editPrinter.html
+++ b/host/resourcesnew/editPrinter.html
@@ -39,6 +39,16 @@