diff --git a/src/com/t_oster/liblasercut/LaserJob.java b/src/com/t_oster/liblasercut/LaserJob.java index bab035fa31fd262529ef0e5867e4fe8d080388ff..8b4c4bd8b98028a5f6e08e87d00d05c1f82ed0ea 100644 --- a/src/com/t_oster/liblasercut/LaserJob.java +++ b/src/com/t_oster/liblasercut/LaserJob.java @@ -2,17 +2,17 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ @@ -22,6 +22,8 @@ */ package com.t_oster.liblasercut; +import com.sun.java_cup.internal.runtime.virtual_parse_stack; +import com.t_oster.liblasercut.platform.Util; import java.util.LinkedList; import java.util.List; @@ -35,8 +37,8 @@ public class LaserJob private String title; private String name; private String user; - private int startX = 0; - private int startY = 0; + private double startX = 0; + private double startY = 0; private List<JobPart> parts = new LinkedList<JobPart>(); public LaserJob(String title, String name, String user) @@ -46,18 +48,26 @@ public class LaserJob this.user = user; } - public void setStartPoint(int x, int y) + /** + * Sets a custom offset on the job. The values are considered to be in + * mm and measured from the top-left corner of the laserbed. + * As a result, all coordinates cx,cy in the job will be corrected + * to cx-x,cy-y + * @param x + * @param y + */ + public void setStartPoint(double x, double y) { startX = x; startY = y; } - public int getStartX() + public double getStartX() { return startX; } - public int getStartY() + public double getStartY() { return startY; } @@ -81,14 +91,55 @@ public class LaserJob { this.parts.add(p); } - + public void removePart(JobPart p) { this.parts.remove(p); } - + public List<JobPart> getParts() { return parts; } + + /** + * This mehtod will substract the start-point coordinates + * from all parts of the job (in the corresponding resolution) + * and then set the start-point to 0,0. This way multiple calls + * to this method won't result in corrupted jobs. + */ + public void applyStartPoint() + { + if (startX != 0 || startY != 0) + { + for (JobPart p : this.getParts()) + { + if (p instanceof VectorPart) + { + for (VectorCommand c : ((VectorPart) p).getCommandList()) + { + if (c.getType().equals(VectorCommand.CmdType.LINETO) || c.getType().equals(VectorCommand.CmdType.MOVETO)) + { + c.setX((int) (c.getX() - Util.mm2inch(startX)*p.getDPI())); + c.setY((int) (c.getY() - Util.mm2inch(startY)*p.getDPI())); + } + } + } + else if (p instanceof RasterPart) + { + RasterPart rp = (RasterPart) p; + rp.start.x -= (int) (Util.mm2inch(startX)*p.getDPI()); + rp.start.y -= (int) (Util.mm2inch(startY)*p.getDPI()); + } + else if (p instanceof Raster3dPart) + { + Raster3dPart rp = (Raster3dPart) p; + rp.start.x -= (int) (Util.mm2inch(startX)*p.getDPI()); + rp.start.y -= (int) (Util.mm2inch(startY)*p.getDPI()); + } + } + startX = 0; + startY = 0; + } + } } diff --git a/src/com/t_oster/liblasercut/Raster3dPart.java b/src/com/t_oster/liblasercut/Raster3dPart.java index f8171fe6cdb8c4a141bfac9198408fd936deee8d..46688188e09ee5a6d0fe5625b865b82da772a363 100644 --- a/src/com/t_oster/liblasercut/Raster3dPart.java +++ b/src/com/t_oster/liblasercut/Raster3dPart.java @@ -16,10 +16,6 @@ * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. * */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package com.t_oster.liblasercut; import com.t_oster.liblasercut.platform.Point; @@ -35,7 +31,7 @@ public class Raster3dPart extends JobPart private GreyscaleRaster image = null; private LaserProperty property = null; - private Point start = null; + protected Point start = null; private double resolution = 500; public Raster3dPart(GreyscaleRaster image, LaserProperty laserProperty, Point offset, double resolution) @@ -51,7 +47,7 @@ public class Raster3dPart extends JobPart { return resolution; } - + @Override public int getMinX() { @@ -69,7 +65,7 @@ public class Raster3dPart extends JobPart { return start.y; } - + @Override public int getMaxY() { diff --git a/src/com/t_oster/liblasercut/RasterPart.java b/src/com/t_oster/liblasercut/RasterPart.java index 5e7093114274ec303d072071ca25be7b3990e22d..893c2c726b49a05cc1d333627d92b1a491fbc0b8 100644 --- a/src/com/t_oster/liblasercut/RasterPart.java +++ b/src/com/t_oster/liblasercut/RasterPart.java @@ -2,24 +2,20 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package com.t_oster.liblasercut; import com.t_oster.liblasercut.platform.Point; @@ -51,13 +47,13 @@ public class RasterPart extends JobPart { return resolution; } - + @Override public int getMinX() { return this.start.x; } - + @Override public int getMaxX() { @@ -69,7 +65,7 @@ public class RasterPart extends JobPart { return start.y; } - + @Override public int getMaxY() { @@ -79,7 +75,7 @@ public class RasterPart extends JobPart /** * Returns the upper left point of the given raster * @param raster the raster which upper left corner is to determine - * @return + * @return */ public Point getRasterStart() { @@ -92,7 +88,7 @@ public class RasterPart extends JobPart * 1 when black or 0 when white * @param raster * @param line - * @return + * @return */ public List<Byte> getRasterLine(int line) { @@ -108,7 +104,7 @@ public class RasterPart extends JobPart { return this.image.isBlack(x, y); } - + public int getRasterWidth() { return this.image.getWidth(); @@ -123,5 +119,5 @@ public class RasterPart extends JobPart { return this.property; } - + } diff --git a/src/com/t_oster/liblasercut/VectorCommand.java b/src/com/t_oster/liblasercut/VectorCommand.java index 44f69c3e5fd59d0b00bfa8a7866d07a77a648f35..e740eabdda1325f2c46a2ef59eccaf8a6a775a37 100644 --- a/src/com/t_oster/liblasercut/VectorCommand.java +++ b/src/com/t_oster/liblasercut/VectorCommand.java @@ -2,17 +2,17 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ @@ -29,6 +29,30 @@ package com.t_oster.liblasercut; public class VectorCommand { + void setX(int d) + { + if (this.type == CmdType.MOVETO || this.type == CmdType.LINETO) + { + operands[0] = d; + } + else + { + throw new UnsupportedOperationException("setX not supported for " + type.toString()); + } + } + + void setY(int d) + { + if (this.type == CmdType.MOVETO || this.type == CmdType.LINETO) + { + operands[1] = d; + } + else + { + throw new UnsupportedOperationException("setY not supported for " + type.toString()); + } + } + public static enum CmdType { @@ -40,7 +64,7 @@ public class VectorCommand private int[] operands; private float foperand; private LaserProperty property; - + public VectorCommand(CmdType type, int x, int y) { if (type == CmdType.MOVETO || type == CmdType.LINETO) @@ -56,7 +80,7 @@ public class VectorCommand throw new IllegalArgumentException("Wrong number of Parameters for " + type.toString()); } } - + public VectorCommand(CmdType type, LaserProperty p) { if (type == CmdType.SETPROPERTY) @@ -92,7 +116,7 @@ public class VectorCommand } throw new UnsupportedOperationException("getX not supported for " + type.toString()); } - + public LaserProperty getProperty() { if (this.type == CmdType.SETPROPERTY) @@ -104,5 +128,5 @@ public class VectorCommand throw new UnsupportedOperationException("Only valid for PROPERTY"); } } - + } diff --git a/src/com/t_oster/liblasercut/VectorPart.java b/src/com/t_oster/liblasercut/VectorPart.java index 9537a7ef346703c6f81816619d6aedd27e85e199..f12dd0f1051f8c3a7fb338e70b1175c1e0e9ad12 100644 --- a/src/com/t_oster/liblasercut/VectorPart.java +++ b/src/com/t_oster/liblasercut/VectorPart.java @@ -2,24 +2,20 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ package com.t_oster.liblasercut; import java.util.LinkedList; @@ -50,7 +46,7 @@ public class VectorPart extends JobPart commands = new LinkedList<VectorCommand>(); this.currentCuttingProperty = initialProperty; commands.add(new VectorCommand(VectorCommand.CmdType.SETPROPERTY, initialProperty)); - + } @Override @@ -58,7 +54,7 @@ public class VectorPart extends JobPart { return resolution; } - + public LaserProperty getCurrentCuttingProperty() { return currentCuttingProperty; @@ -118,7 +114,7 @@ public class VectorPart extends JobPart { return minX; } - + @Override public int getMaxX() { @@ -130,7 +126,7 @@ public class VectorPart extends JobPart { return minY; } - + @Override public int getMaxY() { diff --git a/src/com/t_oster/liblasercut/drivers/Dummy.java b/src/com/t_oster/liblasercut/drivers/Dummy.java index 780bd00ad900dee7132cf55e57f134dec9b78af8..8c27a0d56a9a3adec462c60f3abadb26ac049107 100644 --- a/src/com/t_oster/liblasercut/drivers/Dummy.java +++ b/src/com/t_oster/liblasercut/drivers/Dummy.java @@ -26,7 +26,7 @@ import java.util.*; /** * This class implements a dummy driver that accepts laserjobs and prints debug information about them. * You can use it to test the VisiCut GUI without having a real lasercutter. - * + * * @author Max Gaukler <development@maxgaukler.de>, based on the LAOS driver by Thomas Oster <thomas.oster@rwth-aachen.de> */ public class Dummy extends LaserCutter { @@ -45,6 +45,7 @@ public class Dummy extends LaserCutter { BufferedOutputStream out; pl.taskChanged(this, "checking job"); checkJob(job); + job.applyStartPoint(); pl.taskChanged(this, "sending"); pl.taskChanged(this, "sent."); System.out.println("dummy-driver got LaserJob: "); @@ -90,7 +91,7 @@ public class Dummy extends LaserCutter { System.out.println("end of job."); pl.progressChanged(this, 100); } - + @Override public int estimateJobDuration(LaserJob job) { @@ -99,12 +100,12 @@ public class Dummy extends LaserCutter { if (!canEstimateJobDuration()) { throw new RuntimeException("cannot estimate job duration (dummy driver: fake runtime is set to negative value)"); } - // return bogus value to test codepaths of GUI + // return bogus value to test codepaths of GUI return fakeRunTime; } - + private List<Double> resolutions; - + protected int fakeRunTime = -1; @Override public boolean canEstimateJobDuration() { @@ -192,7 +193,7 @@ public class Dummy extends LaserCutter { } else if (SETTING_RUNTIME.equals(attribute)) { this.fakeRunTime=Integer.parseInt(value.toString()); } - + } @Override diff --git a/src/com/t_oster/liblasercut/drivers/EpilogCutter.java b/src/com/t_oster/liblasercut/drivers/EpilogCutter.java index a5cff64843f01520674c5ec68dc2b1498973c33d..156bd3ad5adea55bc206ba8bf37cbdef2bb52c82 100644 --- a/src/com/t_oster/liblasercut/drivers/EpilogCutter.java +++ b/src/com/t_oster/liblasercut/drivers/EpilogCutter.java @@ -2,17 +2,17 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ @@ -45,7 +45,7 @@ abstract class EpilogCutter extends LaserCutter public static boolean SIMULATE_COMMUNICATION = false; public static final int NETWORK_TIMEOUT = 3000; /* Resolutions in DPI */ - + private static final int MINFOCUS = -500;//Minimal focus value (not mm) private static final int MAXFOCUS = 500;//Maximal focus value (not mm) private static final double FOCUSWIDTH = 0.0252;//How much mm/unit the focus values are @@ -90,12 +90,12 @@ abstract class EpilogCutter extends LaserCutter { return this.autofocus; } - + public void setAutoFocus(boolean af) { this.autofocus = af; } - + private void waitForResponse(int expected) throws IOException, Exception { waitForResponse(expected, 3); @@ -143,12 +143,12 @@ abstract class EpilogCutter extends LaserCutter if (this.isAutoFocus()) { /* Set autofocus on. */ - out.printf("\033&y1A"); + out.printf("\033&y1A"); } else { /* Set autofocus off. */ - out.printf("\033&y0A"); + out.printf("\033&y0A"); } /* Set focus to 0. */ out.printf("\033&y0C"); @@ -303,6 +303,7 @@ abstract class EpilogCutter extends LaserCutter public void realSendJob(LaserJob job, ProgressListener pl, int number, int count) throws UnsupportedEncodingException, IOException, UnknownHostException, Exception { + job.applyStartPoint(); String nb = count > 1 ? "("+number+"/"+count+")" : ""; pl.taskChanged(this, "generating"+nb); //Generate all the data @@ -319,7 +320,7 @@ abstract class EpilogCutter extends LaserCutter //disconnect disconnect(); } - + @Override public void sendJob(LaserJob job, ProgressListener pl) throws IllegalJobException, SocketTimeoutException, UnsupportedEncodingException, IOException, UnknownHostException, Exception { @@ -362,6 +363,7 @@ abstract class EpilogCutter extends LaserCutter { number++; LaserJob j = new LaserJob((size > 1 ? "("+number+"/"+size+")" : "" )+job.getTitle(), job.getName(), job.getUser()); + j.setStartPoint(job.getStartX(), job.getStartY()); for (JobPart p:current) { j.addPart(p); @@ -541,7 +543,7 @@ abstract class EpilogCutter extends LaserCutter out.printf("\033*rC"); // end raster return result.toByteArray(); } - + private byte[] generateRasterPCL(RasterPart rp) throws UnsupportedEncodingException, IOException { PowerSpeedFocusProperty prop = (PowerSpeedFocusProperty) rp.getLaserProperty(); @@ -646,7 +648,7 @@ abstract class EpilogCutter extends LaserCutter out.printf("WF%d;", 0); return result.toByteArray(); } - + private byte[] generateVectorPCL(VectorPart vp) throws UnsupportedEncodingException { //TODO: Test if the resolution settings have an effect @@ -662,8 +664,6 @@ abstract class EpilogCutter extends LaserCutter Integer currentSpeed = null; Integer currentFrequency = null; Float currentFocus = null; - int sx = 0; - int sy = 0; VectorCommand.CmdType lastType = null; for (VectorCommand cmd : vp.getCommandList()) { @@ -700,18 +700,18 @@ abstract class EpilogCutter extends LaserCutter } case MOVETO: { - out.printf("PU%d,%d;", cmd.getX() - sx, cmd.getY() - sy); + out.printf("PU%d,%d;", cmd.getX(), cmd.getY()); break; } case LINETO: { if (lastType == null || lastType != VectorCommand.CmdType.LINETO) { - out.printf("PD%d,%d", cmd.getX() - sx, cmd.getY() - sy); + out.printf("PD%d,%d", cmd.getX(), cmd.getY()); } else { - out.printf(",%d,%d", cmd.getX() - sx, cmd.getY() - sy); + out.printf(",%d,%d", cmd.getX(), cmd.getY()); } break; } @@ -884,7 +884,7 @@ abstract class EpilogCutter extends LaserCutter { return true; } - + @Override public int estimateJobDuration(LaserJob job) { @@ -995,5 +995,5 @@ abstract class EpilogCutter extends LaserCutter { return Math.sqrt(Math.pow(p.x - x, 2) + Math.pow(p.y - y, 2)); } - + } diff --git a/src/com/t_oster/liblasercut/drivers/LaosCutter.java b/src/com/t_oster/liblasercut/drivers/LaosCutter.java index 5aa65d20d15c7b4b861b9bc141ecc757b98079ea..368db7206c4828da7898fab0135fb054918533b5 100644 --- a/src/com/t_oster/liblasercut/drivers/LaosCutter.java +++ b/src/com/t_oster/liblasercut/drivers/LaosCutter.java @@ -2,17 +2,17 @@ * This file is part of VisiCut. * Copyright (C) 2012 Thomas Oster <thomas.oster@rwth-aachen.de> * RWTH Aachen University - 52062 Aachen, Germany - * + * * VisiCut is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * VisiCut is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with VisiCut. If not, see <http://www.gnu.org/licenses/>. **/ @@ -46,7 +46,7 @@ import org.apache.commons.net.tftp.TFTPClient; * This class implements a driver for the LAOS Lasercutter board. * Currently it supports the simple code and the G-Code, which may be used in * the future. - * + * * @author Thomas Oster <thomas.oster@rwth-aachen.de> */ public class LaosCutter extends LaserCutter @@ -62,37 +62,37 @@ public class LaosCutter extends LaserCutter private static final String SETTING_TFTP = "Use TFTP instead of TCP"; private static final String SETTING_RASTER_WHITESPACE = "Additional space per Raster line"; private static final String SETTING_UNIDIR = "Engrave unidirectional"; - + private boolean unidir = false; - + @Override public LaosCutterProperty getLaserPropertyForVectorPart() { return new LaosCutterProperty(); } - + @Override public LaosCutterProperty getLaserPropertyForRasterPart() { return new LaosCutterProperty(); } - + @Override public LaosCutterProperty getLaserPropertyForRaster3dPart() { return new LaosCutterProperty(); } - + public void setEngraveUnidirectional(boolean uni) { this.unidir = uni; } - + public boolean isEngraveUnidirectional() { return this.unidir; } - + private double addSpacePerRasterLine = 5; /** @@ -117,7 +117,7 @@ public class LaosCutter extends LaserCutter this.addSpacePerRasterLine = addSpacePerRasterLine; } - + @Override public String getModelName() { @@ -165,7 +165,7 @@ public class LaosCutter extends LaserCutter { this.flipXaxis = flipXaxis; } - + protected boolean flipYaxis = true; /** @@ -187,7 +187,7 @@ public class LaosCutter extends LaserCutter { this.flipYaxis = flipYaxis; } - + protected String hostname = "192.168.123.111"; /** @@ -285,7 +285,7 @@ public class LaosCutter extends LaserCutter { out.printf("0 %d %d\n", px2steps(isFlipXaxis() ? Util.mm2px(bedWidth, resolution) - x : x, resolution), px2steps(isFlipYaxis() ? Util.mm2px(bedHeight, resolution) - y : y, resolution)); } - + private void loadBitmapLine(PrintStream out, List<Long> dwords) { out.printf("9 %s %s ", "1", ""+(dwords.size()*32)); @@ -295,7 +295,7 @@ public class LaosCutter extends LaserCutter } out.printf("\n"); } - + private float currentPower = -1; private void setPower(PrintStream out, float power) { @@ -305,7 +305,7 @@ public class LaosCutter extends LaserCutter currentPower = power; } } - + private float currentSpeed = -1; private void setSpeed(PrintStream out, float speed) { @@ -315,7 +315,7 @@ public class LaosCutter extends LaserCutter currentSpeed = speed; } } - + private int currentFrequency = -1; private void setFrequency(PrintStream out, int frequency) { @@ -325,7 +325,7 @@ public class LaosCutter extends LaserCutter currentFrequency = frequency; } } - + private float currentFocus = 0; private void setFocus(PrintStream out, float focus) { @@ -335,7 +335,7 @@ public class LaosCutter extends LaserCutter currentFocus = focus; } } - + private Boolean currentVentilation = null; private void setVentilation(PrintStream out, boolean ventilation) { @@ -345,7 +345,7 @@ public class LaosCutter extends LaserCutter currentVentilation = ventilation; } } - + private Boolean currentPurge = null; private void setPurge(PrintStream out, boolean purge) { @@ -355,7 +355,7 @@ public class LaosCutter extends LaserCutter currentPurge = purge; } } - + private void setCurrentProperty(PrintStream out, LaserProperty p) { if (p instanceof LaosCutterProperty) @@ -371,9 +371,9 @@ public class LaosCutter extends LaserCutter else { throw new RuntimeException("The Laos driver only accepts LaosCutter properties (was "+p.getClass().toString()+")"); - } + } } - + private void line(PrintStream out, float x, float y, double resolution) { out.printf("1 %d %d\n", px2steps(isFlipXaxis() ? Util.mm2px(bedWidth, resolution) - x : x, resolution), px2steps(isFlipYaxis() ? Util.mm2px(bedHeight, resolution) - y : y, resolution)); @@ -467,7 +467,7 @@ public class LaosCutter extends LaserCutter } /** - * This Method takes a raster-line represented by a list of bytes, + * This Method takes a raster-line represented by a list of bytes, * where: byte0 ist the left-most byte, in one byte, the MSB is the * left-most bit, 0 representing laser off, 1 representing laser on. * The Output List of longs, where each value is the unsigned dword @@ -479,7 +479,7 @@ public class LaosCutter extends LaserCutter * rightmost bit * @param line * @param outputLeftToRight - * @return + * @return */ public List<Long> byteLineToDwords(List<Byte> line, boolean outputLeftToRight) { @@ -492,7 +492,7 @@ public class LaosCutter extends LaserCutter for(int i=0; i<s; i+=4) { result.add( - (((long) (i+3 < s ? 0xFF&line.get(i+3) : 0))<<24) + (((long) (i+3 < s ? 0xFF&line.get(i+3) : 0))<<24) + (((long) (i+2 < s ? 0xFF&line.get(i+2) : 0))<<16) + (((long) (i+1 < s ? 0xFF&line.get(i+1) : 0))<<8) + ((long) (0xFF&line.get(i))) @@ -502,13 +502,13 @@ public class LaosCutter extends LaserCutter { Collections.reverse(result); for(int i=0;i<result.size();i++) - { + { result.set(i, Long.reverse(result.get(i)) >>> 32); } } return result; } - + private byte[] generateLaosRasterCode(RasterPart rp, double resolution) throws UnsupportedEncodingException, IOException { ByteArrayOutputStream result = new ByteArrayOutputStream(); @@ -549,11 +549,11 @@ public class LaosCutter extends LaserCutter { bytes.add((byte) 0); space -= 8; - } + } if (dirRight) { //move to the first point of the line - move(out, lineStart.x, lineStart.y, resolution); + move(out, lineStart.x, lineStart.y, resolution); List<Long> dwords = this.byteLineToDwords(bytes, true); loadBitmapLine(out, dwords); line(out, lineStart.x + (dwords.size()*32), lineStart.y, resolution); @@ -562,9 +562,9 @@ public class LaosCutter extends LaserCutter { //move to the first point of the line List<Long> dwords = this.byteLineToDwords(bytes, false); - move(out, lineStart.x+(dwords.size()*32), lineStart.y, resolution); + move(out, lineStart.x+(dwords.size()*32), lineStart.y, resolution); loadBitmapLine(out, dwords); - line(out, lineStart.x, lineStart.y, resolution); + line(out, lineStart.x, lineStart.y, resolution); } } if (!this.isEngraveUnidirectional()) @@ -574,7 +574,7 @@ public class LaosCutter extends LaserCutter } return result.toByteArray(); } - + private byte[] generateInitializationCode() throws UnsupportedEncodingException { ByteArrayOutputStream result = new ByteArrayOutputStream(); @@ -618,7 +618,7 @@ public class LaosCutter extends LaserCutter out.write(this.generateShutdownCode()); out.close(); } - + @Override public void sendJob(LaserJob job, ProgressListener pl) throws IllegalJobException, Exception { @@ -627,6 +627,7 @@ public class LaosCutter extends LaserCutter ByteArrayOutputStream buffer = null; pl.taskChanged(this, "checking job"); checkJob(job); + job.applyStartPoint(); if (!useTftp) { pl.taskChanged(this, "connecting"); diff --git a/src/com/t_oster/liblasercut/drivers/Lasersaur.java b/src/com/t_oster/liblasercut/drivers/Lasersaur.java index 2b56d540f04e0495ef6144e1b30f6d99aa7ef413..38cb55b1554ccbd62d47669f6d25fde1b282bc17 100644 --- a/src/com/t_oster/liblasercut/drivers/Lasersaur.java +++ b/src/com/t_oster/liblasercut/drivers/Lasersaur.java @@ -371,6 +371,7 @@ public class Lasersaur extends LaserCutter { BufferedOutputStream out; pl.taskChanged(this, "checking job"); checkJob(job); + job.applyStartPoint(); pl.taskChanged(this, "connecting"); CommPortIdentifier cpi = null; //since the CommPortIdentifier.getPortIdentifier(String name) method