summaryrefslogtreecommitdiff
path: root/print
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2021-12-18 08:44:37 +0100
committerGitHub <noreply@github.com>2021-12-18 08:44:37 +0100
commit1d3cb680c4ec253165fb5cd183e8b4e920f635be (patch)
treef17f5e55d4e510dc04f41d764065519bc69916ff /print
parentffeb265e5310e3c899c27f5364b070c09e50e5ff (diff)
PDF: Estimated thread (#1389)
Diffstat (limited to 'print')
-rw-r--r--print/resources/inkstitch.js27
-rw-r--r--print/templates/operator_overview.html5
-rw-r--r--print/templates/print_overview.html2
-rw-r--r--print/templates/ui.html22
4 files changed, 53 insertions, 3 deletions
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js
index 8bdc4ec0..01908246 100644
--- a/print/resources/inkstitch.js
+++ b/print/resources/inkstitch.js
@@ -146,6 +146,16 @@ function writeEstimatedTime( selector, estimatedTime ) {
$(selector).text( hours + ':' + minutes + ':' + seconds );
}
+function setEstimatedThread() {
+ var multiplyThread = ($('#multiply-thread').val() == '') ? 2 : parseInt($('#multiply-thread').val());
+ var estimatedThread = (parseFloat($('#estimated-thread').text()) * multiplyThread).toFixed(2);
+ var multiplyBobbin = ($('#multiply-bobbin').val() == '') ? 1 : parseInt($('#multiply-bobbin').val());
+ var estimatedBobbin = (parseFloat($('#estimated-thread').text()) * multiplyBobbin).toFixed(2);
+ $('.total-estimated-thread').each(function(index, item) {
+ $(this).text(estimatedThread + "m / " + estimatedBobbin + "m");
+ })
+}
+
// Scale SVG (fit || full size)
function scaleSVG(element, scale = 'fit') {
@@ -596,6 +606,20 @@ $(function() {
$('.modal').hide();
});
+ // Estimated thread and bobbin
+ $('#multiply-thread').on('input initialize', function() {
+ setEstimatedThread();
+ }).on('change', function() {
+ var field_name = $(this).attr('data-field-name');
+ $.postJSON('/settings/' + field_name, {value: $(this).val()});
+ });
+ $('#multiply-bobbin').on('input initialize', function() {
+ setEstimatedThread();
+ }).on('change', function() {
+ var field_name = $(this).attr('data-field-name');
+ $.postJSON('/settings/' + field_name, {value: $(this).val()});
+ });
+
// View selection checkboxes
$(':checkbox.view').on('change initialize', function() {
var field_name = $(this).attr('data-field-name');
@@ -684,6 +708,7 @@ $(function() {
setTimeout(function() {
setEstimatedTime();
+ setEstimatedThread();
}, 100);
$('button.svg-realistic').click(function(e){
@@ -729,6 +754,8 @@ $(function() {
settings["time-opo"] = $("[data-field-name='time-opo']").val();
settings["time-opd"] = $("[data-field-name='time-opd']").val();
+ settings["multiply-thread"] = $("[data-field-name='multiply-thread']").val();
+
$.postJSON('/defaults', {'value': settings});
});
});
diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html
index a7f33a85..f61c2a6f 100644
--- a/print/templates/operator_overview.html
+++ b/print/templates/operator_overview.html
@@ -12,8 +12,9 @@
<div>
<div class="table">
<p><span>{{ _('Design box size') }}:</span><span>{{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }}</span></p>
- <p><span>{{ _('Total stitch count') }}:</span><span>{{job.num_stitches }}</span></p>
- <p><span>{{ _('Total thread used') }}:</span><span>{{job.total_thread_used }}</span></p>
+ <p><span>{{ _('Total stitch count') }}:</span><span>{{ job.num_stitches }}</span></p>
+ <p><span>{{ _('Total thread used') }}:</span><span class="total-estimated-thread"></span></p>
+ <p style="display:none;" id="estimated-thread">{{ job.estimated_thread }}</p>
</div>
</div>
<div>
diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html
index 04269e20..7d09ff1a 100644
--- a/print/templates/print_overview.html
+++ b/print/templates/print_overview.html
@@ -13,7 +13,7 @@
<div class="table">
<p><span>{{ _('Design box size') }}:</span><span>{{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }}</span></p>
<p><span>{{ _('Total stitch count') }}:</span><span>{{job.num_stitches }}</span></p>
- <p><span>{{ _('Total thread used') }}:</span><span>{{job.estimated_thread }}</span></p>
+ <p><span>{{ _('Total thread used') }}:</span><span class="total-estimated-thread"></span></p>
</div>
</div>
<div>
diff --git a/print/templates/ui.html b/print/templates/ui.html
index 57c17205..dd61e2d8 100644
--- a/print/templates/ui.html
+++ b/print/templates/ui.html
@@ -19,6 +19,7 @@
<button class="tab active">{{ _('Page Setup') }}</button>
<button class="tab" id="branding-tab">{{ _('Branding') }}</button>
<button class="tab">{{ _('Estimated Time') }}</button>
+ <button class="tab">{{ _('Estimated Thread') }}</button>
<button class="tab">{{ _('Design') }}</button>
</div>
@@ -142,6 +143,27 @@
<button class="save-settings" title="{{ _('Includes page setup, estimated time and also the branding.') }}">{{ _("Save as defaults") }}</button>
</fieldset>
+ <fieldset id="ui-time" class="ui-tab">
+ <legend>{{ _('Estimated Thread') }}</legend>
+ <fieldset>
+ <legend>{{ _('Factors') }}</legend>
+ <p>{{ _('The thread length calculation depends on a lot of factors in embroidery designs. We will only get a very inacurate approximation.
+ Ink/Stitch simply calculates the path length, so the factor of 1 will always be much, much less than the real thread consumption.') }}</p>
+ <p>{{ _('Set a factor to multiply the path length with, depending on your standard setup or adapt it to your current design (tension, thread, fabric, stitch count, etc.).') }}</p>
+ <p><b>Upper thread</b></p>
+ <p>
+ <input type="number" id="multiply-thread" data-field-name="multiply-thread" min="1" value="2" />
+ <label for="multiply-thread" title="{{ _('Factor to multiply with thread length') }}">{{ _('* path length') }}</label>
+ </p>
+ <p><b>Bobbin</b></p>
+ <p>
+ <input type="number" id="multiply-bobbin" data-field-name="multiply-bobbin" min="1" value="1" />
+ <label for="multiply-bobbin" title="{{ _('Factor to multiply with thread length') }}">{{ _('* path length') }}</label>
+ </p>
+ </fieldset>
+ <button class="save-settings" title="{{ _('Includes page setup, estimated time and also the branding.') }}">{{ _("Save as defaults") }}</button>
+ </fieldset>
+
<fieldset id="ui-design" class="ui-tab">
<legend>{{ _('Design') }}</legend>
<p class="select-container"><label for="thread-palette">{{ _('Thread Palette') }}:</label>