mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 03:23:48 +01:00
parent
222a27d5b5
commit
1f4ca15442
@ -23,6 +23,7 @@ import createSceneData from 'doodle3d-core/d3/createSceneData.js';
|
|||||||
import { generateExportMesh } from 'doodle3d-core/utils/exportUtils.js';
|
import { generateExportMesh } from 'doodle3d-core/utils/exportUtils.js';
|
||||||
import { Matrix4 } from 'three/src/math/Matrix4.js';
|
import { Matrix4 } from 'three/src/math/Matrix4.js';
|
||||||
import muiThemeable from 'material-ui/styles/muiThemeable';
|
import muiThemeable from 'material-ui/styles/muiThemeable';
|
||||||
|
import Dialog from 'material-ui/Dialog';
|
||||||
|
|
||||||
const MAX_FULLSCREEN_WIDTH = 720;
|
const MAX_FULLSCREEN_WIDTH = 720;
|
||||||
|
|
||||||
@ -121,6 +122,10 @@ class Interface extends React.Component {
|
|||||||
popover: {
|
popover: {
|
||||||
element: null,
|
element: null,
|
||||||
open: false
|
open: false
|
||||||
|
},
|
||||||
|
openUrlDialog: {
|
||||||
|
open: true,
|
||||||
|
url: ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -222,8 +227,12 @@ class Interface extends React.Component {
|
|||||||
const updateProgres = progress => this.setState({ progress: { ...this.state.progress, ...progress } });
|
const updateProgres = progress => this.setState({ progress: { ...this.state.progress, ...progress } });
|
||||||
await slice(target, name, exportMesh, settings, updateProgres);
|
await slice(target, name, exportMesh, settings, updateProgres);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.setState({ error: error.message });
|
if (error.code === 3) {
|
||||||
throw error;
|
this.setState({ openUrlDialog: { open: true, url: error.url } });
|
||||||
|
} else {
|
||||||
|
this.setState({ error: error.message });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.setState({ isSlicing: false });
|
this.setState({ isSlicing: false });
|
||||||
}
|
}
|
||||||
@ -288,7 +297,7 @@ class Interface extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { classes, onCancel } = this.props;
|
const { classes, onCancel } = this.props;
|
||||||
const { isSlicing, isLoading, progress, showFullScreen, error, objectDimensions } = this.state;
|
const { isSlicing, isLoading, progress, showFullScreen, error, objectDimensions, openUrlDialog } = this.state;
|
||||||
|
|
||||||
const disableUI = isSlicing || isLoading;
|
const disableUI = isSlicing || isLoading;
|
||||||
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
|
const style = { ...(showFullScreen ? {} : { maxWidth: 'inherit', width: '100%', height: '100%' }) };
|
||||||
@ -352,6 +361,32 @@ class Interface extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const closeDialog = () => this.setState({ openUrlDialog: { open: false, url: '' } });
|
||||||
|
|
||||||
|
const dialog = (
|
||||||
|
<Dialog
|
||||||
|
open={openUrlDialog.open}
|
||||||
|
title="Open with Doodle3D Connect"
|
||||||
|
contentStyle={{ maxWidth: '400px' }}
|
||||||
|
actions={[
|
||||||
|
<FlatButton
|
||||||
|
label="Cancel"
|
||||||
|
onTouchTap={closeDialog}
|
||||||
|
/>,
|
||||||
|
<FlatButton
|
||||||
|
label="Open"
|
||||||
|
primary
|
||||||
|
onTouchTap={() => {
|
||||||
|
window.open(openUrlDialog.url, '_blank');
|
||||||
|
closeDialog();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<p>Click 'Open' to continue to Doodle3D Connect</p>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
|
||||||
if (showFullScreen) {
|
if (showFullScreen) {
|
||||||
return (
|
return (
|
||||||
<div className={classes.container}>
|
<div className={classes.container}>
|
||||||
@ -359,6 +394,7 @@ class Interface extends React.Component {
|
|||||||
<h1 className={classes.title}>Doodle3D Slicer</h1>
|
<h1 className={classes.title}>Doodle3D Slicer</h1>
|
||||||
{d3Panel}
|
{d3Panel}
|
||||||
{settingsPanel}
|
{settingsPanel}
|
||||||
|
{dialog}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -379,6 +415,7 @@ class Interface extends React.Component {
|
|||||||
{d3Panel}
|
{d3Panel}
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
{dialog}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ const GCODE_SERVER_URL = 'https://gcodeserver.doodle3d.com';
|
|||||||
const CONNECT_URL = 'http://connect.doodle3d.com/';
|
const CONNECT_URL = 'http://connect.doodle3d.com/';
|
||||||
|
|
||||||
export async function slice(target, name, mesh, settings, updateProgress) {
|
export async function slice(target, name, mesh, settings, updateProgress) {
|
||||||
if (!settings) throw new Error('please select a printer first');
|
if (!settings) throw { message: 'please select a printer first', code: 0 };
|
||||||
|
|
||||||
let steps;
|
let steps;
|
||||||
let currentStep = 0;
|
let currentStep = 0;
|
||||||
@ -130,7 +130,7 @@ export async function slice(target, name, mesh, settings, updateProgress) {
|
|||||||
steps = 2;
|
steps = 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('unknown target');
|
throw { message: 'unknown target', code: 1 };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,6 +144,8 @@ export async function slice(target, name, mesh, settings, updateProgress) {
|
|||||||
action: progress.action,
|
action: progress.action,
|
||||||
percentage: currentStep / steps + progress.done / progress.total / steps
|
percentage: currentStep / steps + progress.done / progress.total / steps
|
||||||
});
|
});
|
||||||
|
}).catch(error => {
|
||||||
|
throw { message: `error during slicing: ${error.message}`, code: 2 };
|
||||||
});
|
});
|
||||||
currentStep ++;
|
currentStep ++;
|
||||||
|
|
||||||
@ -182,13 +184,14 @@ export async function slice(target, name, mesh, settings, updateProgress) {
|
|||||||
});
|
});
|
||||||
currentStep ++;
|
currentStep ++;
|
||||||
|
|
||||||
const popup = window.open(`${CONNECT_URL}?uuid=${id}`, '_blank');
|
const url = `${CONNECT_URL}?uuid=${id}`;
|
||||||
if (!popup) throw new Error('popup was blocked by browser');
|
const popup = window.open(url, '_blank');
|
||||||
|
if (!popup) throw { message: 'popup was blocked by browser', code: 3, url };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error('unknown target');
|
throw { message: 'unknown target', code: 1 };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user