use of com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method scanSurfaceButtonActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void scanSurfaceButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_scanSurfaceButtonActionPerformed
if (scanner == null || scanner.getProbeStartPositions() == null || scanner.getProbeStartPositions().isEmpty()) {
return;
}
scanningSurface = true;
try {
Units u = this.unitMM.isSelected() ? Units.MM : Units.INCH;
AutoLevelSettings als = settings.getAutoLevelSettings();
for (Position p : scanner.getProbeStartPositions()) {
backend.sendGcodeCommand(true, String.format("G90 G21 G0 X%f Y%f Z%f", p.x, p.y, p.z));
backend.probe("Z", als.probeSpeed, this.scanner.getProbeDistance(), u);
backend.sendGcodeCommand(true, String.format("G90 G21 G0 Z%f", p.z));
}
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
} finally {
scanningSurface = false;
}
}
use of com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method updateSettings.
private void updateSettings() {
this.bulkChanges = true;
// Only set units radio button the first time.
if (!this.unitInch.isSelected() && !this.unitMM.isSelected()) {
Units u = settings.getPreferredUnits();
this.unitInch.setSelected(u == Units.INCH);
this.unitMM.setSelected(u == Units.MM);
}
AutoLevelSettings als = settings.getAutoLevelSettings();
this.stepResolution.setValue(als.stepResolution);
this.zSurface.setValue(als.zSurface);
this.bulkChanges = false;
this.stateChanged(null);
}
use of com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method stateChanged.
/**
* The preview parameters were changed.
*/
@Override
public void stateChanged(ChangeEvent e) {
// This state change handler is only for the visualizer.
if (bulkChanges || scanner == null) {
return;
}
Units units = this.unitInch.isSelected() ? Units.INCH : Units.MM;
Settings.AutoLevelSettings autoLevelSettings = updateScanner(units);
autoLevelSettings.zSurface = getValue(this.zSurface);
autoLevelSettings.stepResolution = getValue(this.stepResolution);
// prevent infinite loop, only call when the stateChange event was triggered by a swing component.
if (e != null) {
settings.setAutoLevelSettings(autoLevelSettings);
}
}
use of com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method applyToGcodeActionPerformed.
// GEN-LAST:event_dataViewerActionPerformed
private void applyToGcodeActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_applyToGcodeActionPerformed
GcodeParser gcp = new GcodeParser();
Settings.AutoLevelSettings autoLevelSettings = this.settings.getAutoLevelSettings();
// Step 0: Get rid of comments.
gcp.addCommandProcessor(new CommentProcessor());
// Step 1: The arc processor and line processors NO LONGER need to be split!
// Step 2: Must convert arcs to line segments.
gcp.addCommandProcessor(new ArcExpander(true, autoLevelSettings.autoLevelArcSliceLength));
// Step 3: Line splitter. No line should be longer than some fraction of "resolution"
gcp.addCommandProcessor(new LineSplitter(getValue(stepResolution) / 10));
// Step 4: Adjust Z heights codes based on mesh offsets.
gcp.addCommandProcessor(new MeshLeveler(getValue(this.zSurface), scanner.getProbePositionGrid(), scanner.getUnits()));
try {
backend.applyGcodeParser(gcp);
} catch (Exception ex) {
GUIHelpers.displayErrorDialog(ex.getMessage());
Exceptions.printStackTrace(ex);
}
}
use of com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method updateScanner.
private AutoLevelSettings updateScanner(Units units) {
Settings.AutoLevelSettings autoLevelerSettings = this.settings.getAutoLevelSettings();
double xOff = autoLevelerSettings.autoLevelProbeOffset.x;
double yOff = autoLevelerSettings.autoLevelProbeOffset.y;
Position corner1 = new Position(getValue(xMin) + xOff, getValue(yMin) + yOff, getValue(zMin), units);
Position corner2 = new Position(getValue(xMax) + xOff, getValue(yMax) + yOff, getValue(zMax), units);
autoLevelerSettings.stepResolution = getValue(this.stepResolution);
autoLevelerSettings.zSurface = getValue(this.zSurface);
scanner.update(corner1, corner2, autoLevelerSettings.stepResolution);
if (r != null) {
r.updateSettings(scanner.getProbeStartPositions(), scanner.getUnits(), scanner.getProbePositionGrid(), scanner.getMaxXYZ(), scanner.getMinXYZ());
}
return autoLevelerSettings;
}
Aggregations