Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes on probing #2281

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ugs-core/src/resources/MessagesBundle_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ probe.measure-rate = Slow measure rate
probe.x-distance = Probe X Distance
probe.y-distance = Probe Y Distance
probe.retract-amount = Retract amount
probe.retract-amount.tooltip = Distance to retract after the fast probe cycle before running the slow probe
probe.hole-diameter = Approximate hole diameter
probe.hole-center-hint = Move probe to approximate center
probe.work-coordinates = Work Coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public class ProbeParameters {
public final double holeDiameter;
public final double feedRate;
public final double feedRateSlow;

/**
* The distance to retract after first fast probe cycle before running the next slow probe cycle
*/
public final double retractAmount;
public final WorkCoordinateSystem wcsToUpdate;
public final UnitUtils.Units units;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public final class ProbeTopComponent extends TopComponent implements UGSEventLis
public final static String ProbeActionId = "com.willwinder.ugs.platform.probe.ProbeTopComponent.renamed";
public final static String ProbeCategory = LocalizingService.CATEGORY_WINDOW;
// hole diameter tab
private static final String HC_TAB = "HC";
private static final String HC_TAB = "Hole center";
// xyz tab
private static final String XYZ_TAB = "XYZ";
// outside tab
Expand Down Expand Up @@ -163,7 +163,17 @@ public void componentOpened() {

@Override
public void componentClosed() {
probePreviewManager.clear();
probePreviewManager.inactivate();
}

@Override
protected void componentHidden() {
probePreviewManager.inactivate();
}

@Override
protected void componentShowing() {
probePreviewManager.activate();
}

@OnStart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void setEnabled(boolean enabled) {
@Override
public void UGSEvent(UGSEvent evt) {
if (evt instanceof ControllerStateEvent) {
setEnabled(isEnabled());
SwingUtilities.invokeLater(() -> setEnabled(isEnabled()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void register(String name, AbstractProbePreview probePreview) {
}

public void setActive(String name) {
clear();
inactivate();
AbstractProbePreview currentPreview = probePreviewMap.get(name);
activePreview.set(currentPreview);
if (currentPreview != null) {
Expand All @@ -46,7 +46,7 @@ public void setActive(String name) {
}
}

public void clear() {
public void inactivate() {
AbstractProbePreview currentPreview = activePreview.get();
if (currentPreview != null) {
RenderableUtils.removeRenderable(currentPreview);
Expand All @@ -66,4 +66,11 @@ public void updateSettings() {
currentPreview.updateSettings();
}
}

public void activate() {
AbstractProbePreview currentPreview = activePreview.get();
if (currentPreview != null) {
RenderableUtils.registerRenderable(currentPreview);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ private void createLayout() {
add(new JSpinner(settingsSlowMeasureRate), "growx");

add(new JLabel(Localization.getString("probe.retract-amount") + ":"), "al right");
add(new JSpinner(settingsRetractAmount), "growx");
JSpinner retractSpinner = new JSpinner(settingsRetractAmount);
retractSpinner.setToolTipText(Localization.getString("probe.retract-amount.tooltip"));
add(retractSpinner, "growx");
}

private void registerListeners() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public void componentOpened() {

if (autoLevelPreview == null) {
autoLevelPreview = new AutoLevelPreview(Localization.getString("platform.visualizer.renderable.autolevel-preview"));
RenderableUtils.registerRenderable(autoLevelPreview);
}

initComponents();
Expand All @@ -117,6 +116,20 @@ public void componentClosed() {
meshLevelManager.clear();
}

@Override
protected void componentHidden() {
if (autoLevelPreview != null) {
RenderableUtils.removeRenderable(autoLevelPreview);
}
}

@Override
protected void componentShowing() {
if (autoLevelPreview != null) {
RenderableUtils.registerRenderable(autoLevelPreview);
}
}

private void updatePreview() {
if (autoLevelPreview != null) {
autoLevelPreview.updateSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ public void probeEvent(final Position p) {
Position expectedProbePosition = pendingPositions.pop();
Position probedPosition = p.getPositionIn(expectedProbePosition.getUnits());

if (!isEqual(probedPosition.getX(), expectedProbePosition.getX(), 0.0001) || !isEqual(probedPosition.getY(), expectedProbePosition.getY(), 0.0001)) {
// The position reported from controller might lack some precision on the X/Y position.
// We therefore need to lower the precision when checking the probed X/Y axes
double delta = expectedProbePosition.getUnits() == Units.MM ? 0.01 : 0.001;
if (!isEqual(probedPosition.getX(), expectedProbePosition.getX(), delta) || !isEqual(probedPosition.getY(), expectedProbePosition.getY(), delta)) {
reset();
throw new RuntimeException(String.format("Unexpected probe location, expected %s to be %s", probedPosition, expectedProbePosition));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public AutoLevelerPanel(SurfaceScanner surfaceScanner, MeshLevelManager meshLeve
}

private void initComponents() {
xMin = new Spinner(autoLevelSettings.getMinZ());
xMin = new Spinner(autoLevelSettings.getMinX());
yMin = new Spinner(autoLevelSettings.getMinY());
zMin = new Spinner(autoLevelSettings.getMinZ());
xMax = new Spinner(autoLevelSettings.getMaxX(), 0.0001);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ This file is part of Universal Gcode Sender (UGS).

import java.awt.*;
import java.awt.event.InputEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -111,7 +111,7 @@ public class GcodeRenderer implements GLEventListener, IRenderableRegistrationSe
private Overlay overlay;
private final String dimensionsLabel = "";

private final ArrayList<Renderable> objects;
private final java.util.List<Renderable> objects;
private boolean idle = true;

// Preferences
Expand All @@ -133,7 +133,7 @@ public GcodeRenderer() {
setVerticalTranslationVector();
setHorizontalTranslationVector();

objects = new ArrayList<>();
objects = new CopyOnWriteArrayList<>();
objects.add(new MachineBoundries(Localization.getString("platform.visualizer.renderable.machine-boundries")));
objects.add(new Tool(Localization.getString("platform.visualizer.renderable.tool-location")));
objects.add(new MouseOver(Localization.getString("platform.visualizer.renderable.mouse-indicator")));
Expand Down