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);
}
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();
}
Aggregations