Skip to content

Commit

Permalink
make sure the show and hide ops take place on the UI thread
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Dec 27, 2024
1 parent 876682d commit dc5f0a5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
57 changes: 30 additions & 27 deletions src/main/java/com/commonwealthrobotics/allign/AllignHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class AllignHandle {
private BowlerStudio3dEngine engine;

private HashMap<CSG,MeshView> visualizers = new HashMap<>();
private HashMap<CSG, MeshView> visualizers = new HashMap<>();
private double scale;

public Allignment self;
Expand All @@ -42,7 +42,6 @@ public class AllignHandle {

private Allign opperation;


private List<CSG> toAllign;

private List<String> selected;
Expand Down Expand Up @@ -80,14 +79,15 @@ public MeshView getHandle() {
mesh.setMaterial(material);
exited = event -> {
material.setDiffuseColor(Color.BLACK);
for(CSG key:visualizers.keySet()) {
for (CSG key : visualizers.keySet()) {
visualizers.get(key).setVisible(false);
}
};
entered = event -> {
material.setDiffuseColor(new Color(1, 0, 0, 1));
//com.neuronrobotics.sdk.common.Log.error("ENtered " + self + " " + orentation);
for(CSG key:visualizers.keySet()) {
// com.neuronrobotics.sdk.common.Log.error("ENtered " + self + " " +
// orentation);
for (CSG key : visualizers.keySet()) {
visualizers.get(key).setVisible(true);
}
};
Expand Down Expand Up @@ -116,12 +116,12 @@ public MeshView getHandle() {
}

private void setMyOperation() {
if(isXvector())
opperation.x=self;
if(isYvector())
opperation.y=self;
if(isZvector())
opperation.z=self;
if (isXvector())
opperation.x = self;
if (isYvector())
opperation.y = self;
if (isZvector())
opperation.z = self;
}

public void threeDTarget(double screenW, double screenH, double zoom, Bounds b, TransformNR cf) {
Expand Down Expand Up @@ -231,7 +231,8 @@ public void threeDTarget(double screenW, double screenH, double zoom, Bounds b,

setScale(scaleFactor);

// com.neuronrobotics.sdk.common.Log.error("Point From Cam distaance "+vect+" scale "+scale);
// com.neuronrobotics.sdk.common.Log.error("Point From Cam distaance "+vect+"
// scale "+scale);
// com.neuronrobotics.sdk.common.Log.error("");
BowlerStudio.runLater(() -> {
scaleTF.setX(getScale());
Expand Down Expand Up @@ -274,10 +275,12 @@ public void initialize(Allign opperation, BowlerStudio3dEngine engine, List<CSG>
}

public void hide() {
getHandle().setVisible(false);
for(CSG key:visualizers.keySet()) {
visualizers.get(key).setVisible(false);
}
BowlerStudio.runLater(() -> {
getHandle().setVisible(false);
for (CSG key : visualizers.keySet()) {
visualizers.get(key).setVisible(false);
}
});
}

public void setOnClickCallback(Runnable onClick) {
Expand All @@ -294,22 +297,22 @@ public void reset() {
}

public void recomputeOps() {
Allignment x= opperation.x;
Allignment y=opperation.y;
Allignment z=opperation.z;
Allignment x = opperation.x;
Allignment y = opperation.y;
Allignment z = opperation.z;
setMyOperation();
if(visualizationObjects!=null) {
for(CSG obj:visualizationObjects) {

if (visualizationObjects != null) {
for (CSG obj : visualizationObjects) {
MeshView mv = visualizers.remove(obj);
engine.removeUserNode(mv);
}
}
visualizationObjects = opperation.process(toAllign);
for(CSG indicator:visualizationObjects) {
for (CSG indicator : visualizationObjects) {
MeshView indicatorMesh = indicator.newMesh();
indicatorMesh.setMouseTransparent(true);
//indicatorMesh.getTransforms().addAll(workplaneOffset);
// indicatorMesh.getTransforms().addAll(workplaneOffset);
PhongMaterial material = new PhongMaterial();

if (indicator.isHole()) {
Expand All @@ -326,9 +329,9 @@ public void recomputeOps() {
indicatorMesh.setVisible(false);
visualizers.put(indicator, indicatorMesh);
}
opperation.x=x;
opperation.y=y;

opperation.x = x;
opperation.y = y;
opperation.z = z;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void hide() {
r.hide();
}
for (Node n : getElements()) {
n.setVisible(false);
BowlerStudio.runLater(()->n.setVisible(false));
}
}

Expand Down

0 comments on commit dc5f0a5

Please sign in to comment.