Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Commit

Permalink
configs fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Владислав Чалый committed Feb 6, 2023
1 parent 4c02dd6 commit 483c422
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/renderer/Shared/Config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Restore } from './Libs/Restore';

export const _default = {
version: 42,
version: 44,
versionPrinterConfigs: 0,
settings: {
ui: {
Expand Down Expand Up @@ -57,7 +57,7 @@ export const _default = {
main: '#5e48ff'
}
},
workerCount: 15,
workerCount: 30,
printerName: '',
pathToUVTools: '/uvtools/UVtoolsCmd.exe',
pathToSave: 'C:\\',
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/Shared/Libs/Restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ const parseDataFile = (filePath, defaults) => {

if(defaults.version && parsed.version !== defaults.version)
{
return defaults;
return {
...defaults,
...parsed,
version: defaults.version
};
}

return parsed;
Expand Down
22 changes: 13 additions & 9 deletions src/renderer/Slicing/SlicingStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ export class SlicingStore {

this.sliceCount += 1;

if (this.sliceCount > this.sliceCountMax) {
AppStore.instance.progressPercent = 1;
break;
}
else {
AppStore.instance.progressPercent = (this.sliceCount/this.sliceCountMax);
}

if (!this.isWorking)
{
Log('slicing cancelled!');
Expand All @@ -115,6 +107,9 @@ export class SlicingStore {

const created = SceneObject.CreateClipping(SceneObject.CalculateSceneGeometry()).group.toJSON();

let reportStateCount = 0;
const reportStateCountMax = this.sliceCountMax;

const workerSpawn = (layers: { i: number, percent: number }[]) => {
return new Promise(resolve => {
const worker = new Worker(bridge.assetsPath() + '/workers/slice.worker.bundle.js');
Expand All @@ -124,9 +119,18 @@ export class SlicingStore {
switch (e.data.type)
{
case SliceWorkerResultType.SliceResult:
reportStateCount++;

bridge.ipcRenderer.send('sliced-layer-save',
e.data.image.replace('data:image/png;base64,',''),
(e.data.layer.i + 1)+'.png');

if (reportStateCount >= reportStateCountMax) {
AppStore.instance.progressPercent = 1;
}
else {
AppStore.instance.progressPercent = (reportStateCount/reportStateCountMax);
}
return;
case SliceWorkerResultType.JobDone:
worker.terminate();
Expand Down Expand Up @@ -181,7 +185,6 @@ export class SlicingStore {

public registrationReceivers = () => {
const store = AppStore.sceneStore;
const printer = AppStore.sceneStore.printer!;

if (bridge.isWorker()) {
bridge.ipcRenderer.send('prepare-to-slicing-worker-ready');
Expand Down Expand Up @@ -215,6 +218,7 @@ export class SlicingStore {
Log('prepare to slicing done!');
this.isWorking = true;
const maxObjectsPoint = _.maxBy(store.objects, (x: SceneObject) => x.maxY.y);
const printer = AppStore.sceneStore.printer!;
this.sliceTo = Math.min(store.gridSize.y, maxObjectsPoint!.maxY.y);
this.sliceCountMax = Math.ceil(this.sliceTo / (printer.PrintSettings.LayerHeight * 0.1));
this.sliceCount = 0;
Expand Down

0 comments on commit 483c422

Please sign in to comment.