use of com.willwinder.universalgcodesender.utils.Settings.FileStats in project Universal-G-Code-Sender by winder.
the class GUIBackend method initializeProcessedLines.
private void initializeProcessedLines(boolean forceReprocess, File startFile, GcodeParser gcodeParser) throws Exception {
if (startFile != null) {
try (FileReader fr = new FileReader(startFile)) {
Charset.forName(fr.getEncoding());
}
logger.info("Start preprocessing");
long start = System.currentTimeMillis();
if (this.processedGcodeFile == null || forceReprocess) {
gcp.reset();
String name = startFile.getName();
// If this is being re-processed, strip the ugs postfix and try again.
Pattern word = Pattern.compile("(.*)_ugs_[\\d]+$");
Matcher match = word.matcher(name);
if (match.matches()) {
name = match.group(1);
}
this.processedGcodeFile = new File(this.getTempDir(), name + "_ugs_" + System.currentTimeMillis());
this.preprocessAndExportToFile(gcodeParser, startFile, this.processedGcodeFile);
// Store gcode file stats.
GcodeStats gs = gcp.getCurrentStats();
this.settings.setFileStats(new FileStats(gs.getMin(), gs.getMax(), gs.getCommandCount()));
}
long end = System.currentTimeMillis();
logger.info("Took " + (end - start) + "ms to preprocess");
if (this.isConnected()) {
this.estimatedSendDuration = -1L;
Thread estimateThread = new Thread(() -> estimatedSendDuration = controller.getJobLengthEstimate(processedGcodeFile));
estimateThread.start();
}
}
}
use of com.willwinder.universalgcodesender.utils.Settings.FileStats in project Universal-G-Code-Sender by winder.
the class RendererInputHandler method updateBounds.
/**
* Pass new bounds (after interpolating arcs) in case of weird arcs.
*/
private void updateBounds(Point3d min, Point3d max) {
// Update bounds.
FileStats fs = settings.getFileStats();
fs.minCoordinate = new Position(min.x, min.y, min.z, Units.MM);
fs.maxCoordinate = new Position(max.x, max.y, max.z, Units.MM);
settings.setFileStats(fs);
}
use of com.willwinder.universalgcodesender.utils.Settings.FileStats in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method useLoadedFileActionPerformed.
// GEN-LAST:event_settingsButtonActionPerformed
private void useLoadedFileActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_useLoadedFileActionPerformed
if (backend.getProcessedGcodeFile() == null) {
return;
}
FileStats fs = backend.getSettings().getFileStats();
Units u = this.unitMM.isSelected() ? Units.MM : Units.INCH;
Position min = fs.minCoordinate.getPositionIn(u);
Position max = fs.maxCoordinate.getPositionIn(u);
this.xMin.setValue(min.x);
this.yMin.setValue(min.y);
this.zMin.setValue(min.z);
this.xMax.setValue(max.x);
this.yMax.setValue(max.y);
this.zMax.setValue(max.z);
}
Aggregations