diff --git a/libraries/bowler-script-kernel b/libraries/bowler-script-kernel index 50aa5d1c8..8c8b05934 160000 --- a/libraries/bowler-script-kernel +++ b/libraries/bowler-script-kernel @@ -1 +1 @@ -Subproject commit 50aa5d1c86395a7731db78f97b60fda852b1f69c +Subproject commit 8c8b05934e2038fe4aece1ed26e5b8d61628c8d4 diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLab.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLab.java index 74076c61b..bed1eeea5 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLab.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLab.java @@ -19,6 +19,8 @@ import com.neuronrobotics.sdk.util.ThreadUtil; import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.beans.property.Property; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.fxml.FXMLLoader; @@ -46,10 +48,15 @@ public class CreatureLab extends AbstractBowlerStudioTab implements IOnEngineeri private ProgressIndicator pi; private MobileBaseCadManager baseManager; - private CheckBox autoRegen = new CheckBox("Auto-Regen CAD"); + private CheckBox autoRegen = new CheckBox("Auto-Generate CAD"); + private Button regen=new Button("Generate Cad Now"); Parent root; private BowlerJInputDevice gameController = null; - CreatureLabControlsTab tab = new CreatureLabControlsTab();; + CreatureLabControlsTab tab = new CreatureLabControlsTab(); + + private long timeSinceLastUpdate = 0; + + private HBox radioOptions;; @Override public void onTabClosing() { @@ -68,11 +75,14 @@ public void initializeUI(BowlerAbstractDevice pm) { setGraphic(AssetFactory.loadIcon("CreatureLab-Tab.png")); this.pm = pm; autoRegen.setSelected(true); + + disable(); autoRegen.setOnAction(event -> { - baseManager.setAutoRegen(autoRegen.isSelected()); - if (autoRegen.isSelected()) { - generateCad(); - } + regenFromUiEvent(); + }); + regen.setOnAction(event -> { + autoRegen.setSelected(true); + regenFromUiEvent(); }); // TODO Auto-generated method stub setText(pm.getScriptingName()); @@ -110,7 +120,7 @@ public void initializeUI(BowlerAbstractDevice pm) { // TODO Auto-generated catch block e1.printStackTrace(); } - while(getContent()==null) + while (getContent() == null) try { Thread.sleep(100); } catch (InterruptedException e) { @@ -119,6 +129,30 @@ public void initializeUI(BowlerAbstractDevice pm) { } } + private void regenFromUiEvent() { + BowlerStudio.runLater(() -> { + + if (System.currentTimeMillis() - timeSinceLastUpdate < 500) { + return; + } + timeSinceLastUpdate = System.currentTimeMillis(); + if (autoRegen.isSelected()) { + disable(); + } + baseManager.setAutoRegen(autoRegen.isSelected()); + if (autoRegen.isSelected()) { + generateCad(); + } + }); + } + + private void disable() { + autoRegen.setDisable(true); + if (radioOptions != null) + radioOptions.setDisable(true); + regen.setDisable(true); + } + private void finishLoading(MobileBase device) { TreeItem rootItem = null; @@ -170,8 +204,8 @@ private void finishLoading(MobileBase device) { rootItemFinal.setExpanded(true); MobileBaseCadManager.get(device, BowlerStudioController.getMobileBaseUI()); - MobleBaseMenueFactory.load(device, tree, mainBaseFinal, callbackMapForTreeitems, widgetMapForTreeitems, this, - true, creatureIsOwnedByUser); + MobleBaseMenueFactory.load(device, tree, mainBaseFinal, callbackMapForTreeitems, widgetMapForTreeitems, + this, true, creatureIsOwnedByUser); tree.setPrefWidth(325); tree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); JogMobileBase walkWidget = new JogMobileBase(device); @@ -232,28 +266,52 @@ public void run() { setCadMode(true); }); - HBox radioOptions = new HBox(10); + radioOptions = new HBox(10); radioOptions.getChildren().addAll(new Label("Cad"), rb1, rb2, new Label("Config")); pi = new ProgressIndicator(0); baseManager = MobileBaseCadManager.get(device, BowlerStudioController.getMobileBaseUI()); pi.progressProperty().bindBidirectional(baseManager.getProcesIndictor()); HBox progressIndicatorPanel = new HBox(10); - progressIndicatorPanel.getChildren().addAll(new Label("Cad Progress:"), pi); - progress.getChildren().addAll(progressIndicatorPanel, autoRegen, radioOptions); - progress.setStyle("-fx-background-color: #FFFFFF;"); - progress.setOpacity(.7); - progress.setMinHeight(100); - progress.setPrefSize(325, 150); - tab.setOverlayTop(progress); + progress.getChildren().addAll( regen,autoRegen, radioOptions); + progressIndicatorPanel.getChildren().addAll( progress,pi); + + progressIndicatorPanel.setStyle("-fx-background-color: #FFFFFF;"); + progressIndicatorPanel.setOpacity(.7); + progressIndicatorPanel.setMinHeight(100); + progressIndicatorPanel.setPrefSize(325, 150); + tab.setOverlayTop(progressIndicatorPanel); BowlerStudioModularFrame.getBowlerStudioModularFrame().showCreatureLab(); setCadMode(true);// start the UI in config mode generateCad(); - } + pi.progressProperty().addListener(new ChangeListener() { + + @Override + public void changed(ObservableValue observable, Number oldValue, Number newValue) { + System.out.println("Progress listener " + newValue); + if (newValue.doubleValue() > 0.99) { + BowlerStudio.runLater(() -> { + enable(); + }); + }else { + BowlerStudio.runLater(() -> { + disable(); + }); + } + } + + }); + } + private void enable() { + autoRegen.setDisable(false); + if (radioOptions != null) + radioOptions.setDisable(false); + regen.setDisable(false); + } private boolean hasWalking(MobileBase device) { return device.getLegs().size() > 0 || device.getSteerable().size() > 0 || device.getDrivable().size() > 0; } @@ -261,10 +319,7 @@ private boolean hasWalking(MobileBase device) { private void setCadMode(boolean mode) { new Thread(() -> { baseManager.setConfigurationViewerMode(mode); - baseManager.setAutoRegen(autoRegen.isSelected()); - if (autoRegen.isSelected()) { - generateCad(); - } + regenFromUiEvent(); }).start(); } diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLabControlsTab.java b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLabControlsTab.java index 1a14b9fc0..750eab81b 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLabControlsTab.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/creature/CreatureLabControlsTab.java @@ -4,6 +4,7 @@ import javafx.fxml.FXML; import javafx.scene.control.TreeView; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; public class CreatureLabControlsTab { @@ -53,7 +54,7 @@ public void setTreeBox(AnchorPane treeBox) { } - public void setOverlayTop(VBox progress) { + public void setOverlayTop(HBox progress) { // TODO Auto-generated method stub BowlerStudio.runLater(()->{ progressBar.getChildren().clear(); diff --git a/src/main/java/com/neuronrobotics/bowlerstudio/threed/Axis.java b/src/main/java/com/neuronrobotics/bowlerstudio/threed/Axis.java index 8f57f827f..2c813f8d6 100644 --- a/src/main/java/com/neuronrobotics/bowlerstudio/threed/Axis.java +++ b/src/main/java/com/neuronrobotics/bowlerstudio/threed/Axis.java @@ -100,7 +100,7 @@ public Axis(int i) { Affine yp = new Affine(); yp.setTy(i / 2); - yText = CSG.unionAll(TextExtrude.text((double)strokWidth,"Y",font)).toYMin().rotz(90).movey(i).moveToCenterX(); + yText = CSG.unionAll(TextExtrude.text((double)strokWidth,"Y",font)).rotz(90).toYMin().movey(i).moveToCenterX(); //yText.getTransforms().add(yp); // zp.setTz(i/2);