Skip to content

Commit

Permalink
Add possibility to export the autoleveled gcode
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed Jan 23, 2024
1 parent 20b3e59 commit 573b7d4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
2 changes: 2 additions & 0 deletions ugs-core/src/resources/MessagesBundle_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ autoleveler.option.offset-y = Probe Y offset
autoleveler.option.offset-z = Probe Z offset
autoleveler.probe-failed = Probe failed
autoleveler.panel.clear = Clear scan
autoleveler.panel.export = Export gcode
autoleveler.panel.export.tooltip = Exports the autoleveled gcode
experimental.feature = This is an experimental feature. Please use caution and report any bugs you find on GitHub.
# Window title for platform GUI
platform-title = Universal Gcode Sender
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2023 Will Winder
Copyright 2023-2024 Will Winder
This file is part of Universal Gcode Sender (UGS).
Expand All @@ -18,11 +18,8 @@ This file is part of Universal Gcode Sender (UGS).
*/
package com.willwinder.ugs.platform.surfacescanner;

import com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils;
import com.willwinder.universalgcodesender.gcode.processors.ArcExpander;
import static com.willwinder.ugs.platform.surfacescanner.Utils.createCommandProcessor;
import com.willwinder.universalgcodesender.gcode.processors.CommandProcessorList;
import com.willwinder.universalgcodesender.gcode.processors.LineSplitter;
import com.willwinder.universalgcodesender.gcode.processors.MeshLeveler;
import com.willwinder.universalgcodesender.model.BackendAPI;
import com.willwinder.universalgcodesender.utils.AutoLevelSettings;
import com.willwinder.universalgcodesender.utils.GUIHelpers;
Expand Down Expand Up @@ -51,19 +48,7 @@ public void update() {
return;
}

commandProcessorList = new CommandProcessorList();

// Step 1: Convert arcs to line segments.
commandProcessorList.add(new ArcExpander(true, autoLevelSettings.getAutoLevelArcSliceLength(), GcodePreprocessorUtils.getDecimalFormatter()));

// Step 2: Line splitter. No line should be longer than some fraction of "resolution"
commandProcessorList.add(new LineSplitter(autoLevelSettings.getStepResolution() / 4));

// Step 3: Adjust Z heights codes based on mesh offsets.
commandProcessorList.add(
new MeshLeveler(autoLevelSettings.getZSurface(),
surfaceScanner.getProbePositionGrid()));

commandProcessorList = createCommandProcessor(autoLevelSettings, surfaceScanner);
backend.applyCommandProcessor(commandProcessorList);
} catch (Exception ex) {
GUIHelpers.displayErrorDialog(ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ This file is part of Universal Gcode Sender (UGS).
*/
package com.willwinder.ugs.platform.surfacescanner;

import com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils;
import com.willwinder.universalgcodesender.gcode.processors.ArcExpander;
import com.willwinder.universalgcodesender.gcode.processors.CommandProcessorList;
import com.willwinder.universalgcodesender.gcode.processors.LineSplitter;
import com.willwinder.universalgcodesender.gcode.processors.MeshLeveler;
import com.willwinder.universalgcodesender.i18n.Localization;
import com.willwinder.universalgcodesender.model.Position;
import com.willwinder.universalgcodesender.model.UnitUtils;
import com.willwinder.universalgcodesender.utils.AutoLevelSettings;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -77,4 +83,20 @@ public static Position getRoundPosition(Position position) {
double z = Math.round(position.getZ() * 1000d) / 1000d;
return new Position(x, y, z, position.getUnits());
}

public static CommandProcessorList createCommandProcessor(AutoLevelSettings autoLevelSettings, SurfaceScanner surfaceScanner) {
CommandProcessorList result = new CommandProcessorList();

// Step 1: Convert arcs to line segments.
result.add(new ArcExpander(true, autoLevelSettings.getAutoLevelArcSliceLength(), GcodePreprocessorUtils.getDecimalFormatter()));

// Step 2: Line splitter. No line should be longer than some fraction of "resolution"
result.add(new LineSplitter(autoLevelSettings.getStepResolution() / 4));

// Step 3: Adjust Z heights codes based on mesh offsets.
result.add(
new MeshLeveler(autoLevelSettings.getZSurface(),
surfaceScanner.getProbePositionGrid()));
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public AutoLevelerToolbar(SurfaceScanner surfaceScanner) {
add(new JButton(new SaveScannedSurfaceAction(surfaceScanner)));
add(new JButton(new ClearScannedSurfaceAction(surfaceScanner)));
add(Box.createGlue());
add(new JButton(new ExportGcodeAction(surfaceScanner)));
add(new JButton(new GenerateTestDataAction(surfaceScanner)));
add(new JButton(new OpenSettingsAction()));
}
Expand Down

0 comments on commit 573b7d4

Please sign in to comment.