Skip to content

Commit 64e0295

Browse files
authored
Add some more FX features (#2766)
1 parent fa977a1 commit 64e0295

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1716
-115
lines changed

.idea/runConfigurations/UGS_FX.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ugs-core/src/com/willwinder/universalgcodesender/connection/ConnectionDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This file is part of Universal Gcode Sender (UGS).
2727
* @author Joacim Breiler
2828
*/
2929
public enum ConnectionDriver {
30-
JSERIALCOMM("JSerialComm", "jserialcomm://"),
30+
JSERIALCOMM("Serial", "jserialcomm://"),
3131
TCP("TCP", "tcp://"),
3232
WS("WebSocket", "ws://");
3333

ugs-core/src/com/willwinder/universalgcodesender/gcode/GcodeParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This file is part of Universal Gcode Sender (UGS).
2424
import com.willwinder.universalgcodesender.gcode.util.Code;
2525
import com.willwinder.universalgcodesender.gcode.util.GcodeParserException;
2626
import com.willwinder.universalgcodesender.gcode.util.GcodeParserUtils;
27+
import com.willwinder.universalgcodesender.model.Position;
2728
import com.willwinder.universalgcodesender.types.PointSegment;
2829

2930
import java.util.ArrayList;
@@ -119,6 +120,7 @@ public void clearCommandProcessors() {
119120
public void reset() {
120121
this.statsProcessor = new Stats();
121122
this.state = new GcodeState();
123+
this.state.currentPoint = Position.INVALID;
122124
this.state.commandNumber = -1;
123125

124126
for (CommandProcessor processor : processors) {

ugs-core/src/com/willwinder/universalgcodesender/gcode/processors/Stats.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ This file is part of Universal Gcode Sender (UGS).
1919
package com.willwinder.universalgcodesender.gcode.processors;
2020

2121
import com.willwinder.universalgcodesender.gcode.GcodeState;
22+
import com.willwinder.universalgcodesender.gcode.GcodeStats;
2223
import com.willwinder.universalgcodesender.gcode.util.GcodeParserException;
2324
import com.willwinder.universalgcodesender.model.Position;
2425
import com.willwinder.universalgcodesender.model.UnitUtils.Units;
26+
2527
import java.util.Collections;
2628
import java.util.List;
27-
import com.willwinder.universalgcodesender.gcode.GcodeStats;
2829

2930
/**
3031
*
@@ -46,14 +47,14 @@ public List<String> processCommand(String command, GcodeState state) throws Gcod
4647
.getPositionIn(defaultUnits);
4748

4849
// Update min
49-
min.x = Math.min(min.x, p.x);
50-
min.y = Math.min(min.y, p.y);
51-
min.z = Math.min(min.z, p.z);
50+
min.x = getMin(min.x, p.x);
51+
min.y = getMin(min.y, p.y);
52+
min.z = getMin(min.z, p.z);
5253

5354
// Update max
54-
max.x = Math.max(max.x, p.x);
55-
max.y = Math.max(max.y, p.y);
56-
max.z = Math.max(max.z, p.z);
55+
max.x = getMax(max.x, p.x);
56+
max.y = getMax(max.y, p.y);
57+
max.z = getMax(max.z, p.z);
5758

5859
// Num commands
5960
commandCount++;
@@ -62,6 +63,24 @@ public List<String> processCommand(String command, GcodeState state) throws Gcod
6263
return Collections.singletonList(command);
6364
}
6465

66+
private double getMin(double value1, double value2) {
67+
if (Double.isNaN(value1)) {
68+
return value2;
69+
} else if(Double.isNaN(value2)) {
70+
return value1;
71+
}
72+
return Math.min(value1, value2);
73+
}
74+
75+
private double getMax(double value1, double value2) {
76+
if (Double.isNaN(value1)) {
77+
return value2;
78+
} else if(Double.isNaN(value2)) {
79+
return value1;
80+
}
81+
return Math.max(value1, value2);
82+
}
83+
6584
@Override
6685
public String getHelp() {
6786
return "Caches program metrics, shouldn't be enabled or disabled.";

ugs-core/src/com/willwinder/universalgcodesender/model/BackendAPI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This file is part of Universal Gcode Sender (UGS).
2121

2222
import com.willwinder.universalgcodesender.IController;
2323
import com.willwinder.universalgcodesender.gcode.GcodeParser;
24+
import com.willwinder.universalgcodesender.gcode.GcodeStats;
2425
import com.willwinder.universalgcodesender.gcode.ICommandCreator;
2526
import com.willwinder.universalgcodesender.gcode.processors.CommandProcessor;
2627
import com.willwinder.universalgcodesender.listeners.ControllerState;
@@ -114,6 +115,7 @@ public interface BackendAPI extends BackendAPIReadOnly {
114115
void sendGcodeCommand(String commandText) throws Exception;
115116
void sendGcodeCommand(boolean restoreParserState, String commandText) throws Exception;
116117
void sendGcodeCommand(GcodeCommand command) throws Exception;
118+
GcodeStats getGcodeStats();
117119

118120
/**
119121
* Jogs the machine by a specified direction given by the partial position.

ugs-core/src/com/willwinder/universalgcodesender/model/GUIBackend.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,4 +799,8 @@ private void initializeProcessedLines(boolean forceReprocess, File startFile, Gc
799799
logger.info("Took " + (end - start) + "ms to preprocess");
800800
}
801801
}
802+
803+
public GcodeStats getGcodeStats() {
804+
return gcp.getCurrentStats();
805+
}
802806
}

ugs-core/src/com/willwinder/universalgcodesender/types/FxSettings.java

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
1+
/*
2+
Copyright 2025 Will Winder
3+
4+
This file is part of Universal Gcode Sender (UGS).
5+
6+
UGS is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
UGS is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with UGS. If not, see <http://www.gnu.org/licenses/>.
18+
*/
119
package com.willwinder.universalgcodesender.types;
220

21+
/**
22+
* Settings for FX window
23+
*
24+
* @author Joacim Breiler
25+
*/
326
public class FxSettings {
27+
28+
private int windowWidth;
29+
private int windowHeight;
30+
private int windowPositionX;
31+
private int windowPositionY;
32+
private double dividerContentPercent;
33+
private double dividerLeftPercent;
34+
435
public FxSettings() {
5-
windowWidth = 640;
6-
windowHeight = 520;
36+
windowWidth = 1024;
37+
windowHeight = 768;
738
windowPositionX = 0;
839
windowPositionY = 0;
940
dividerContentPercent = 0.3;
41+
dividerLeftPercent = 0.5;
1042
}
1143

1244
public int getWindowWidth() {
@@ -49,9 +81,11 @@ public void setDividerContentPercent(double dividerContentPercent) {
4981
this.dividerContentPercent = dividerContentPercent;
5082
}
5183

52-
private int windowWidth;
53-
private int windowHeight;
54-
private int windowPositionX;
55-
private int windowPositionY;
56-
private double dividerContentPercent;
84+
public double getDividerLeftPercent() {
85+
return dividerLeftPercent;
86+
}
87+
88+
public void setDividerLeftPercent(double dividerLeftPercent) {
89+
this.dividerLeftPercent = dividerLeftPercent;
90+
}
5791
}

ugs-core/src/com/willwinder/universalgcodesender/utils/RefreshThread.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public RefreshThread(Runnable refreshFunction, long refreshInterval) {
3434

3535
@Override
3636
public void run() {
37-
while (!Thread.interrupted()) {
37+
while (!Thread.currentThread().isInterrupted()) {
3838
refreshFunction.run();
3939
try {
4040
Thread.sleep(refreshInterval);
4141
} catch (InterruptedException e) {
4242
// Never mind
43+
return;
4344
}
4445
}
4546
}

ugs-core/src/resources/MessagesBundle_en_US.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,3 +765,10 @@ platform.plugin.designer.clipart.weather=Weather
765765
platform.plugin.console.title=Console
766766
platform.plugin.console.action.verbose.disable = Disable verbose logging
767767
platform.plugin.console.action.verbose.enable = Enable verbose logging
768+
settings.general = General settings
769+
settings.machineStatus = Machine status
770+
settings.gamepad = Gamepad
771+
settings.firmware = Firmware
772+
settings.metric = Metric
773+
settings.imperial = Imperial
774+
settings.probe = Probe

ugs-fx/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@
100100
<artifactId>nashorn-core</artifactId>
101101
<version>${ugs.nashorn-core.version}</version>
102102
</dependency>
103+
<dependency>
104+
<groupId>com.willwinder</groupId>
105+
<artifactId>ugs-platform-plugin-designer</artifactId>
106+
<version>2.0-SNAPSHOT</version>
107+
<scope>compile</scope>
108+
</dependency>
103109
</dependencies>
104110

105111
<build>

0 commit comments

Comments
 (0)