-
-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed selection bug overwriting when selecting in the entities tree
Made an attempt to fix the entities tree selection bug where it would overwrite the settings when selecting multiple entities. The design settings has now been moved from the design file to the platform settings.
- Loading branch information
Showing
22 changed files
with
341 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...latform-plugin-designer/src/main/java/com/willwinder/ugs/nbp/designer/gui/ToolButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright 2024 Will Winder | ||
This file is part of Universal Gcode Sender (UGS). | ||
UGS is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
UGS is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with UGS. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.willwinder.ugs.nbp.designer.gui; | ||
|
||
import com.willwinder.ugs.nbp.designer.entities.cuttable.CutType; | ||
import com.willwinder.ugs.nbp.designer.entities.cuttable.Cuttable; | ||
import com.willwinder.ugs.nbp.designer.logic.Controller; | ||
import com.willwinder.universalgcodesender.Utils; | ||
import com.willwinder.universalgcodesender.model.UnitUtils; | ||
|
||
/** | ||
* A button that displays the currently used tool in the design | ||
* | ||
* @author Joacim Breiler | ||
*/ | ||
public class ToolButton extends PanelButton { | ||
private final transient Controller controller; | ||
|
||
public ToolButton(Controller controller) { | ||
super("", ""); | ||
this.controller = controller; | ||
controller.getSettings().addListener(this::updateText); | ||
controller.getDrawing().addListener(e -> updateText()); | ||
controller.getDrawing().getRootEntity().addListener(e -> updateText()); | ||
updateText(); | ||
} | ||
|
||
private static boolean isMillOperation(Cuttable c) { | ||
return c.getCutType() == CutType.ON_PATH || c.getCutType() == CutType.CENTER_DRILL || c.getCutType() == CutType.INSIDE_PATH || c.getCutType() == CutType.OUTSIDE_PATH || c.getCutType() == CutType.POCKET; | ||
} | ||
|
||
private static boolean isLaserOperation(Cuttable c) { | ||
return c.getCutType() == CutType.LASER_FILL || c.getCutType() == CutType.LASER_ON_PATH; | ||
} | ||
|
||
private void updateText() { | ||
setTitle("Tool"); | ||
boolean hasLaserOperations = controller.getDrawing().getEntities().stream() | ||
.filter(Cuttable.class::isInstance) | ||
.map(e -> (Cuttable) e) | ||
.anyMatch(ToolButton::isLaserOperation); | ||
|
||
boolean hasMillOperations = controller.getDrawing().getEntities().stream() | ||
.filter(Cuttable.class::isInstance) | ||
.map(e -> (Cuttable) e) | ||
.anyMatch(ToolButton::isMillOperation); | ||
|
||
|
||
boolean hasMixedOperations = hasLaserOperations && hasMillOperations; | ||
|
||
if (hasMixedOperations) { | ||
setText("Mixed"); | ||
} else if (hasLaserOperations) { | ||
setText("Laser"); | ||
} else { | ||
setText(getMillToolDescription()); | ||
} | ||
} | ||
|
||
public String getMillToolDescription() { | ||
double scale = UnitUtils.scaleUnits(UnitUtils.Units.MM, controller.getSettings().getPreferredUnits()); | ||
return Utils.formatter.format(controller.getSettings().getToolDiameter() * scale) + " " + controller.getSettings().getPreferredUnits().abbreviation; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.