normalize dxf import dialog
This commit is contained in:
parent
17574f76b9
commit
3593be43b5
1 changed files with 46 additions and 22 deletions
|
|
@ -1146,28 +1146,52 @@ function loadSVGDialog(doit) {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function loadDXFDialog(doit) {
|
function loadDXFDialog(doit) {
|
||||||
const opt = {pre: [
|
const rnd = Date.now().toString(36);
|
||||||
"<div class='f-col a-center' style='padding:5px 20px 5px 20px'>",
|
const host = $('mod-any');
|
||||||
" <h3>Import DXF</h3>",
|
host.innerHTML = [
|
||||||
" <p class='t-just' style='width:300px;line-height:1.5em'>",
|
`<div class="image-convert-dialog f-col a-center">`,
|
||||||
" Extrude a 3D model from a 2D DXF.",
|
` <h3 class="image-convert-title">Import DXF</h3>`,
|
||||||
" Supports POLYLINE, LWPOLYLINE, LINE, CIRCLE, ARC, and SPLINE entities.",
|
` <p class="image-convert-copy t-just">`,
|
||||||
" </p>",
|
` Extrude a 3D model from a 2D DXF.`,
|
||||||
" <div class='f-row t-right'><table>",
|
` Supports POLYLINE, LWPOLYLINE, LINE, CIRCLE, ARC, and SPLINE entities.`,
|
||||||
" <tr><th>z height in mm</th><td><input id='dxf-depth' value='5' size='3'></td></tr>",
|
` </p>`,
|
||||||
" <tr><th title='target length of each line segment when converting arcs and circles'>arc segment size in mm</th><td><input id='dxf-seg' value='1' size='3'></td></tr>",
|
` <div class="f-row t-right image-convert-fields"><table>`,
|
||||||
" <tr><th title='minimum number of segments for very small arcs to avoid degenerate geometry'>minimum arc segments</th><td><input id='dxf-min' value='4' size='3'></td></tr>",
|
` <tr><th>z height in mm</th><td><input id="dxf-depth-${rnd}" value="5" size="3"></td></tr>`,
|
||||||
" <tr><th>nest shapes</th><td><input id='dxf-nest' value='1' type='checkbox' checked></td></tr>",
|
` <tr><th title="target length of each line segment when converting arcs and circles">arc segment size in mm</th><td><input id="dxf-seg-${rnd}" value="1" size="3"></td></tr>`,
|
||||||
" </table></div>",
|
` <tr><th title="minimum number of segments for very small arcs to avoid degenerate geometry">minimum arc segments</th><td><input id="dxf-min-${rnd}" value="4" size="3"></td></tr>`,
|
||||||
"</div>"
|
` <tr><th>nest shapes</th><td><input id="dxf-nest-${rnd}" type="checkbox" checked></td></tr>`,
|
||||||
]};
|
` </table></div>`,
|
||||||
api.uc.confirm(undefined, {convert:true, cancel:false}, undefined, opt).then((ok) => {
|
` <div class="f-row j-end image-convert-actions">`,
|
||||||
let depth = Math.max(0.1, parseFloat($('dxf-depth').value));
|
` <button id="dxf-convert-ok-${rnd}">import</button>`,
|
||||||
let segmentSize = Math.max(0.01, parseFloat($('dxf-seg').value));
|
` <button id="dxf-convert-cancel-${rnd}">cancel</button>`,
|
||||||
let minSegments = Math.max(3, parseInt($('dxf-min').value));
|
` </div>`,
|
||||||
let soup = $('dxf-nest').checked;
|
`</div>`
|
||||||
ok && doit({ soup, depth, segmentSize, minSegments });
|
].join('');
|
||||||
|
|
||||||
|
const depth = $(`dxf-depth-${rnd}`);
|
||||||
|
const segmentSize = $(`dxf-seg-${rnd}`);
|
||||||
|
const minSegments = $(`dxf-min-${rnd}`);
|
||||||
|
const nest = $(`dxf-nest-${rnd}`);
|
||||||
|
const okBtn = $(`dxf-convert-ok-${rnd}`);
|
||||||
|
const cancelBtn = $(`dxf-convert-cancel-${rnd}`);
|
||||||
|
|
||||||
|
okBtn.onclick = () => {
|
||||||
|
api.modal.hide();
|
||||||
|
setTimeout(() => {
|
||||||
|
doit({
|
||||||
|
soup: nest.checked,
|
||||||
|
depth: Math.max(0.1, parseFloat(depth.value)),
|
||||||
|
segmentSize: Math.max(0.01, parseFloat(segmentSize.value)),
|
||||||
|
minSegments: Math.max(3, parseInt(minSegments.value))
|
||||||
});
|
});
|
||||||
|
}, 50);
|
||||||
|
};
|
||||||
|
cancelBtn.onclick = () => api.modal.hide();
|
||||||
|
depth.onkeypress = (ev) => {
|
||||||
|
if (ev.key === 'Enter' || ev.charCode === 13) okBtn.click();
|
||||||
|
};
|
||||||
|
api.modal.show('any');
|
||||||
|
setTimeout(() => depth.focus(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue