Skip to content

Commit

Permalink
Adding a ruler Manager #32
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Harrington committed Jan 10, 2025
1 parent 7565a23 commit a3af438
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion BowlerStudio
8 changes: 6 additions & 2 deletions src/main/java/com/commonwealthrobotics/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class MainController implements ICaDoodleStateUpdate, ICameraChangeListen
private ShapesPallet pallet;
private ActiveProject ap = null;
private SelectionBox sb=null;
private RulerManager ruler= new RulerManager();

/**
* CaDoodle Model Classes
Expand Down Expand Up @@ -831,6 +832,10 @@ private void createGroundPlane() {
linesGroupp.setViewOrder(1); // Lower viewOrder renders on top
linesGroupp.getChildren().add(ground);
engine.addUserNode(linesGroupp);
Group rulerGroup = engine.getRulerGroup();
//rulerGroup.getTransforms().add(workplane.getWorkplaneLocation());
ruler.setRulerGroup(rulerGroup);

}

public static double groundScale() {
Expand Down Expand Up @@ -1150,8 +1155,7 @@ public void onInitializationDone() {

@Override
public void onWorkplaneChange(TransformNR newWP) {
// Auto-generated method stub

ruler.setWP(newWP);
}

@Override
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/commonwealthrobotics/RulerManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.commonwealthrobotics;

import com.neuronrobotics.bowlerstudio.BowlerStudio;
import com.neuronrobotics.bowlerstudio.physics.TransformFactory;
import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR;

import javafx.scene.Group;
import javafx.scene.transform.Affine;

public class RulerManager {

private Group rulerGroup;
private Affine wp = new Affine();

public Group getRulerGroup() {
return rulerGroup;
}

public void setRulerGroup(Group rulerGroup) {
this.rulerGroup = rulerGroup;
rulerGroup.getTransforms().add(wp);

}

public void setWP(TransformNR newWP) {
BowlerStudio.runLater(()->TransformFactory.nrToAffine(newWP, wp));
}

}
12 changes: 10 additions & 2 deletions src/main/java/com/commonwealthrobotics/WorkplaneManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void setIndicator(CSG indicator, Affine centerOffset) {
engine.removeUserNode(indicatorMesh);
}
indicatorMesh = indicator.newMesh();
indicatorMesh.getTransforms().addAll(workplaneLocation, centerOffset);
indicatorMesh.getTransforms().addAll(getWorkplaneLocation(), centerOffset);
indicatorMesh.setMouseTransparent(true);

PhongMaterial material = new PhongMaterial();
Expand Down Expand Up @@ -256,7 +256,7 @@ public TransformNR getCurrentAbsolutePose() {

public void setCurrentAbsolutePose(TransformNR currentAbsolutePose) {
this.currentAbsolutePose = currentAbsolutePose;
TransformFactory.nrToAffine(getCurrentAbsolutePose(), workplaneLocation);
TransformFactory.nrToAffine(getCurrentAbsolutePose(), getWorkplaneLocation());
}

public Runnable getOnSelectEvent() {
Expand Down Expand Up @@ -352,4 +352,12 @@ public MeshView getPlacementPlane() {
// Auto-generated method stub
return wpPick;
}

public Affine getWorkplaneLocation() {
return workplaneLocation;
}

public void setWorkplaneLocation(Affine workplaneLocation) {
this.workplaneLocation = workplaneLocation;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a3af438

Please sign in to comment.