Search in sources :

Example 1 with AutoLevelSettings

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;
    }
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Units(com.willwinder.universalgcodesender.model.UnitUtils.Units)

Example 2 with AutoLevelSettings

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);
}
Also used : AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Units(com.willwinder.universalgcodesender.model.UnitUtils.Units)

Example 3 with AutoLevelSettings

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);
    }
}
Also used : AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Units(com.willwinder.universalgcodesender.model.UnitUtils.Units) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Settings(com.willwinder.universalgcodesender.utils.Settings)

Example 4 with 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);
    }
}
Also used : LineSplitter(com.willwinder.universalgcodesender.gcode.processors.LineSplitter) GcodeParser(com.willwinder.universalgcodesender.gcode.GcodeParser) MeshLeveler(com.willwinder.universalgcodesender.gcode.processors.MeshLeveler) ArcExpander(com.willwinder.universalgcodesender.gcode.processors.ArcExpander) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Settings(com.willwinder.universalgcodesender.utils.Settings) CommentProcessor(com.willwinder.universalgcodesender.gcode.processors.CommentProcessor)

Example 5 with AutoLevelSettings

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;
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Settings(com.willwinder.universalgcodesender.utils.Settings)

Aggregations

AutoLevelSettings (com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings)5 Units (com.willwinder.universalgcodesender.model.UnitUtils.Units)3 Settings (com.willwinder.universalgcodesender.utils.Settings)3 Position (com.willwinder.universalgcodesender.model.Position)2 GcodeParser (com.willwinder.universalgcodesender.gcode.GcodeParser)1 ArcExpander (com.willwinder.universalgcodesender.gcode.processors.ArcExpander)1 CommentProcessor (com.willwinder.universalgcodesender.gcode.processors.CommentProcessor)1 LineSplitter (com.willwinder.universalgcodesender.gcode.processors.LineSplitter)1 MeshLeveler (com.willwinder.universalgcodesender.gcode.processors.MeshLeveler)1