Skip to content

Commit

Permalink
Always show segmentation instructions when a DXF or SVG is chosen. Tw…
Browse files Browse the repository at this point in the history
…eak SVG instructions for new Inkscape versions. Fixes #10.
  • Loading branch information
mondalaci committed Jan 24, 2016
1 parent 3e4a22d commit 2b95d35
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
7 changes: 7 additions & 0 deletions index.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ a:visited {
#svg-and-kicad-pcb-save-links,
#advanced-options,
#report-help,
#segmentation-notification,
.invalid-input
{
display: none;
Expand All @@ -46,6 +47,12 @@ a:visited {
color: #f00;
}

#segmentation-notification {
border-left: 8px solid #aaa;
padding-left: 5px;
margin: 10px 0;
}

.upgrade-browser-notification,
.firefox-notification {
background-color: #f88;
Expand Down
21 changes: 15 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,34 @@ <h1>dxf2svg2kicad &mdash; DXF to SVG to KICAD_PCB converter</h1>
<a href="tests/test.svg">test.svg</a> for testing purposes.)</li>
<li>
Check the preview image.
<div id="invalid-input-file" class="invalid-input">
The input file seems invalid! If you're sure it's is valid then
<ol id="dxf-help">
<div id="segmentation-notification">
If the preview image below seems incomplete then
<ol id="dxf-segmentation-notification">
<li>Open it in a CAD application like <a href="http://qcad.org/" target="_blank">QCAD</a>.</li>
<li>Select the whole drawing.</li>
<li>Ese the EXPLODE command.</li>
<li>Save it as a new DXF.</li>
</ol>
<ol id="svg-help">
<ol id="svg-segmentation-notification">
<li>Open it in Inkscape.</li>
<li>Uncheck the "File -> Inkscape Preferences... -> SVG output -> Path data -> Allow relative coordinates" checkbox.</li>
<li>
Set path string format to absolute:
<ul>
<li>For older versions of Inkscape, uncheck the "File -> Inkscape Preferences... ->
SVG output -> Path data -> Allow relative coordinates" checkbox.</li>
<li>For newer versions of Inkscape, set the "Edit -> Preferences... -> Input/Output ->
SVG output -> Path data -> Path string format" option to "Absolute".</li>
</ul>
</li>
<li>Select the "Edit paths by nodes" tool (F2).</li>
<li>Select the whole drawing (Ctrl+A).</li>
<li>Reselect the whole drawing, thereby highlighting the individual nodes (Ctrl+A).</li>
<li>In the node toolbar select "Break path at selected nodes" (Shift+B).</li>
<li>Use the "Path -> Break Apart" command (Shift+Ctrl+K).</li>
<li>Deselect, select and reselect nodes (Esc, Ctrl+A, Ctrl+A).</li>
<li>In the node toolbar select "Make selected segment lines" (Shift+L).</li>
<li>Set the stroke color to black so that you can see the final image (Shift + Left-click on the black color of the palette).</li>
<li>Set the stroke color to black so that you can see the final image
(Shift + Left-click on the black color of the palette).</li>
<li>Save the SVG as a new drawing.</li>
</ol>
Finally, open the newly saved file in dxf2svg2kicad and it should work.
Expand Down
24 changes: 6 additions & 18 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,30 @@ $(document).ready(function() {
switch (fileExtension) {
case 'dxf':
svgString = dxfToSvg(fileData);
$('#svg-and-kicad-pcb-save-links, #dxf-help').show();
$('#invalid-extension, #svg-help').hide();
$('#svg-and-kicad-pcb-save-links, #segmentation-notification, #dxf-segmentation-notification').show();
$('#svg-segmentation-notification, .invalid-input').hide();
break;
case 'svg':
svgString = fileData;
$('#kicad-pcb-save-link, #svg-help').show();
$('#invalid-extension, #dxf-help').hide();
$('#kicad-pcb-save-link, #svg-segmentation-notification, #segmentation-notification').show();
$('#dxf-segmentation-notification, .invalid-input').hide();
break;
default:
$('#no-save-link').show();
$('#invalid-extension').show();
$('#no-save-link, .invalid-input').show();
$('#segmentation-notification').hide();
return;
}

$('#svg-image').remove();

checkConvertedInputString(svgString);
if (svgString === null) {
return;
}

var dataUri = 'data:image/svg+xml;utf8,' + encodeURIComponent(svgString);
var svgImage = $('<img>', {id:'svg-image', src:dataUri});
$('#svg-image-container').append(svgImage);

kicadPcb = svgToKicadPcbGetter(svgString);
checkConvertedInputString(kicadPcb);
})[0].readAsText(file);
});

Expand Down Expand Up @@ -144,15 +141,6 @@ $(document).ready(function() {
return svgToKicadPcb(svgString, filename, layer, translationX, translationY, kicadPcbToBeAppended, fileExtension === 'dxf');
}

function checkConvertedInputString(inputString)
{
if (inputString === null) {
$('#invalid-input-file').show();
} else {
$('#invalid-input-file').hide();
}
}

function saveStringAsFile(string, filename)
{
var blob = new Blob([string], {type: 'text/plain; charset=utf-8'});
Expand Down

0 comments on commit 2b95d35

Please sign in to comment.