From 278e8a2459568028b8d21dac7f07232c5499e5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Kn=C3=B6bel?= Date: Tue, 4 Oct 2016 15:11:41 +0200 Subject: [PATCH] refinement of Art function --- src/cnc/gcode/controller/JPanelArt.java | 16 ++++++++++------ src/cnc/gcode/controller/JPanelCNCMilling.java | 2 +- src/cnc/gcode/controller/JPanelSettings.java | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/cnc/gcode/controller/JPanelArt.java b/src/cnc/gcode/controller/JPanelArt.java index e79908b..d879387 100644 --- a/src/cnc/gcode/controller/JPanelArt.java +++ b/src/cnc/gcode/controller/JPanelArt.java @@ -843,8 +843,7 @@ protected CNCCommand[] doInBackground() throws Exception { g2.translate(img.getWidth()/2,img.getHeight()/2); g2.rotate(Math.PI/180*pa); - //g2.scale(zoom*(pxm?-1:1), zoom*(pym?-1:1)); - g2.scale(zoom, zoom); + g2.scale(zoom*(pxm?-1:1), zoom*(pym?-1:1)); g2.translate(-img.getWidth()/2,-img.getHeight()/2); g2.drawImage(img, 0, 0, null); @@ -967,23 +966,27 @@ protected CNCCommand[] doInBackground() throws Exception { LinkedList cmds = new LinkedList<>(); //Init CNC - cmds.add(CNCCommand.getStartCommand()); + //cmds.add(CNCCommand.getStartCommand()); will be added in CNCMilling cmds.add(new CNCCommand("G0 X"+Tools.dtostr(px)+" Y"+Tools.dtostr(py)+" F"+Tools.dtostr(a.ftravel))); + cmds.add(new CNCCommand("G0 Z"+Tools.dtostr(a.zsave)+" F"+Tools.dtostr(a.ftravel))); //Start Spindel cmds.add(new CNCCommand("M4")); boolean down=false; int count=0; + double lastz=a.zsave; for(ArrayList path:paths) { for(Point p:path){ //calc pos: Point2D.Double ap = new Point2D.Double(px+pxw/pointsx*p.x, py+pyw/pointsy*p.y); - if(!boarder.contains(ap)){ + if(!boarder.contains(ap) || (z[p.x][p.y]>=a.zsave && lastz>=a.zsave)){ if(down){ - cmds.add(new CNCCommand("G0 Z"+Tools.dtostr(a.zsave)+" F"+Tools.dtostr(a.ftravel))); + if(Math.abs(lastz-a.zsave)>0.0001){ + cmds.add(new CNCCommand("G0 Z"+Tools.dtostr(a.zsave)+" F"+Tools.dtostr(a.ftravel))); + } down=false; } } @@ -991,13 +994,14 @@ protected CNCCommand[] doInBackground() throws Exception { { if(!down){ cmds.add(new CNCCommand("G0 X"+Tools.dtostr(ap.x)+" Y"+Tools.dtostr(ap.y)+" F"+Tools.dtostr(a.ftravel))); - cmds.add(new CNCCommand("G1 Z"+Tools.dtostr(z[p.x][p.y])+" F"+Tools.dtostr(a.fmill))); + cmds.add(new CNCCommand("G1 X"+Tools.dtostr(ap.x)+" Y"+Tools.dtostr(ap.y)+" Z"+Tools.dtostr(z[p.x][p.y])+" F"+Tools.dtostr(a.fmill))); down=true; } else{ cmds.add(new CNCCommand("G1 X"+Tools.dtostr(ap.x)+" Y"+Tools.dtostr(ap.y)+" Z"+Tools.dtostr(z[p.x][p.y])+" F"+Tools.dtostr(a.fmill))); } } + lastz=z[p.x][p.y]; } //Move to save height if(down){ diff --git a/src/cnc/gcode/controller/JPanelCNCMilling.java b/src/cnc/gcode/controller/JPanelCNCMilling.java index e26d547..5d121a5 100644 --- a/src/cnc/gcode/controller/JPanelCNCMilling.java +++ b/src/cnc/gcode/controller/JPanelCNCMilling.java @@ -1079,8 +1079,8 @@ public void run() { fireupdateGUI(); } }); - dopause(); } + dopause(); if(cmd.getType() == CNCCommand.Type.ENDPROGRAM && cmds[cmds.length - 1] != cmd) { diff --git a/src/cnc/gcode/controller/JPanelSettings.java b/src/cnc/gcode/controller/JPanelSettings.java index a5cf3f8..918dd4a 100644 --- a/src/cnc/gcode/controller/JPanelSettings.java +++ b/src/cnc/gcode/controller/JPanelSettings.java @@ -666,7 +666,7 @@ private void jBSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI JSettingsDialog.SDouble[] settings= new JSettingsDialog.SDouble[3]; for(int i = 0; i < 3;i++ ) { - settings[i]= new JSettingsDialog.SDouble("Set Size for the " + CommandParsing.axesName[0] + " axis:", DatabaseV2.getWorkspace(i).getsaved()); + settings[i]= new JSettingsDialog.SDouble("Set Size for the " + CommandParsing.axesName[i] + " axis:", DatabaseV2.getWorkspace(i).getsaved()); settings[i].setDmin(Double.MIN_VALUE); }