Search in sources :

Example 1 with Axis

use of com.willwinder.universalgcodesender.model.Axis in project Universal-G-Code-Sender by winder.

the class DROPopup method show.

@Override
public void show(Component invoker, int x, int y) {
    removeAll();
    for (Axis a : Axis.values()) {
        boolean add = a.isLinear();
        // Linear axis by default, or if connected use capabilities.
        if (this.backend.isConnected()) {
            add = this.backend.getController().getCapabilities().hasAxis(a);
        }
        if (add) {
            final JCheckBoxMenuItem menu = new JCheckBoxMenuItem(String.format("Disable Axis: %s", a.name()), !this.settings.isAxisEnabled(a));
            menu.addActionListener(e -> {
                this.settings.setAxisEnabled(a, !menu.isSelected());
            });
            add(menu);
        }
    }
    super.show(invoker, x, y);
}
Also used : Axis(com.willwinder.universalgcodesender.model.Axis)

Example 2 with Axis

use of com.willwinder.universalgcodesender.model.Axis in project Universal-G-Code-Sender by winder.

the class TinyGUtils method generateSetWorkPositionCommand.

/**
 * Generates a command for setting the axis to a position in the current coordinate system
 *
 * @param controllerStatus the current controller status
 * @param gcodeState       the current gcode state
 * @param positions        the position to set
 * @return a command for setting the position
 */
public static String generateSetWorkPositionCommand(ControllerStatus controllerStatus, GcodeState gcodeState, PartialPosition positions) {
    int offsetCode = WorkCoordinateSystem.fromGCode(gcodeState.offset).getPValue();
    UnitUtils.Units currentUnits = gcodeState.getUnits();
    Position machineCoord = controllerStatus.getMachineCoord().getPositionIn(currentUnits);
    PartialPosition.Builder offsets = PartialPosition.builder().setUnits(currentUnits);
    for (Map.Entry<Axis, Double> position : positions.getPositionIn(currentUnits).getAll().entrySet()) {
        double axisOffset = -(position.getValue() - machineCoord.get(position.getKey()));
        offsets.setValue(position.getKey(), axisOffset);
    }
    return "G10 L2 P" + offsetCode + " " + offsets.build().getFormattedGCode();
}
Also used : UnitUtils(com.willwinder.universalgcodesender.model.UnitUtils) Position(com.willwinder.universalgcodesender.model.Position) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) Map(java.util.Map) Axis(com.willwinder.universalgcodesender.model.Axis)

Aggregations

Axis (com.willwinder.universalgcodesender.model.Axis)2 PartialPosition (com.willwinder.universalgcodesender.model.PartialPosition)1 Position (com.willwinder.universalgcodesender.model.Position)1 UnitUtils (com.willwinder.universalgcodesender.model.UnitUtils)1 Map (java.util.Map)1