Search in sources :

Example 1 with TranslateProcessor

use of com.willwinder.universalgcodesender.gcode.processors.TranslateProcessor in project Universal-G-Code-Sender by winder.

the class TranslateToZeroAction method performAction.

@Override
protected void performAction(Node[] activatedNodes) {
    if (!isEnabled()) {
        return;
    }
    ThreadHelper.invokeLater(() -> {
        try {
            LoaderDialogHelper.showDialog("Translating model", 1000);
            File gcodeFile = backend.getProcessedGcodeFile();
            Position offset = getLowerLeftCorner(gcodeFile);
            offset.x = -offset.x;
            offset.y = -offset.y;
            offset.z = 0;
            TranslateProcessor translateProcessor = new TranslateProcessor(offset);
            backend.applyCommandProcessor(translateProcessor);
        } catch (Exception ex) {
            LOGGER.log(Level.SEVERE, "Could not translate gcode", ex);
            GUIHelpers.displayErrorDialog(ex.getLocalizedMessage());
        } finally {
            LoaderDialogHelper.closeDialog();
        }
    });
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) TranslateProcessor(com.willwinder.universalgcodesender.gcode.processors.TranslateProcessor) File(java.io.File) GcodeParserException(com.willwinder.universalgcodesender.gcode.util.GcodeParserException) IOException(java.io.IOException)

Aggregations

TranslateProcessor (com.willwinder.universalgcodesender.gcode.processors.TranslateProcessor)1 GcodeParserException (com.willwinder.universalgcodesender.gcode.util.GcodeParserException)1 PartialPosition (com.willwinder.universalgcodesender.model.PartialPosition)1 Position (com.willwinder.universalgcodesender.model.Position)1 File (java.io.File)1 IOException (java.io.IOException)1