Skip to content

Commit

Permalink
fix inch/mil off by times 10, init units
Browse files Browse the repository at this point in the history
  • Loading branch information
xsrf committed Jan 24, 2021
1 parent 1a438b7 commit 2612929
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 1 addition & 2 deletions extension/locale.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ Solid region (copper fill / keepout, board cutout) = Fläche (copper fill / keep
Track (board outline, silk) = Linien (Umriss, Beschriftung)
(curves will be broken up into segments) = (Kurven werden in Segmente geteilt)
Curve segmentation accuracy (Track import only) = Genauigkeit für Kurven-Segmente (Linien-Import)
Import scale (EasyEDA base unit is 0.1 inch) = Skalierung (EasyEDA verwendet 0.1 Inch als Basis-Einheit)
Import origin (svg origin will be placed here) = SVG Ursprung an dieser Stelle plazieren
Import scale (EasyEDA base unit is 0.01 inch) = Skalierung (EasyEDA verwendet 0.01 Inch als Basis-Einheit)
err_file_not_supported = Dateityp nicht unterstützt, bitte .svg wählen
err_no_paths_found = Keine path-Tags gefunden 😕
err_parsing_all_paths = Fehler beim parsen der path-Tags, siehe Konsole für Details 😕
Expand Down
20 changes: 16 additions & 4 deletions extension/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var svgDocument = '';
var svgPaths = [];
var svgImportLayer = 1;
var unknownCommandFlag = false;
var svgImportUnitsSet = false;

var dlg = api('createDialog', {
title: "SVG Import",
Expand Down Expand Up @@ -51,7 +52,7 @@ var dlg = api('createDialog', {
</div>
</fieldset>
<fieldset>
<legend class="i18n">Import scale (EasyEDA base unit is 0.1 inch)</legend>
<legend class="i18n">Import scale (EasyEDA base unit is 0.01 inch)</legend>
<div>
<input type="number" step="any" name="import-scale" id="import-scale" value="1" size="4" style="width:8em">
<a class="l-btn" cmd="extension-svgimport-set_mil"><span class="l-btn-left"><span class="l-btn-text">mil</span></span></a>
Expand Down Expand Up @@ -131,12 +132,14 @@ api('createCommand', {
},
'extension-svgimport-open' : () => {
getOffsets();
uiUpdateLayerOptions();
initUnits();
uiUpdateLayerOptions();
dlg.dialog('open');
dlg.dialog('expand');
},
'extension-svgimport-openfile' : () => {
getOffsets();
initUnits();
uiUpdateLayerOptions();
dlg.dialog('open');
dlg.dialog('expand');
Expand All @@ -147,11 +150,11 @@ api('createCommand', {
uiDisplayImportScale();
},
'extension-svgimport-set_inch' : () => {
setSvgImportScale(10);
setSvgImportScale(100);
uiDisplayImportScale();
},
'extension-svgimport-set_mil' : () => {
setSvgImportScale(0.01);
setSvgImportScale(0.1);
uiDisplayImportScale();
},
'extension-svgimport-openfiledlg' : () => {
Expand Down Expand Up @@ -194,6 +197,15 @@ api('createToolbarButton', {
]
});

function initUnits() {
if(svgImportUnitsSet) return;
svgImportUnitsSet = true;
var config = api('editorCall', 'getConfig');
if(svgImportScale==1 && config.canvas.unit == 'mm') api('doCommand','extension-svgimport-set_mm');
if(svgImportScale==1 && config.canvas.unit == 'inch') api('doCommand','extension-svgimport-set_inch');
if(svgImportScale==1 && config.canvas.unit == 'mil') api('doCommand','extension-svgimport-set_mil');
}

function uiDisplayImportFlattenAccuracy() {
$('#extension-svgimport-flatten-accuracy').val(svgImportScale);
}
Expand Down

0 comments on commit 2612929

Please sign in to comment.