kopia lustrzana https://github.com/inkstitch/inkstitch
PDF: Estimated thread (#1389)
rodzic
ffeb265e53
commit
1d3cb680c4
lib
extensions
stitch_plan
print
resources
|
@ -287,7 +287,7 @@ class Print(InkstitchExtension):
|
|||
'num_trims': stitch_plan.num_trims,
|
||||
'dimensions': stitch_plan.dimensions_mm,
|
||||
'num_stitches': stitch_plan.num_stitches,
|
||||
'estimated_thread': '', # TODO
|
||||
'estimated_thread': stitch_plan.estimated_thread
|
||||
},
|
||||
svg_overview=overview_svg,
|
||||
color_blocks=stitch_plan.color_blocks,
|
||||
|
|
|
@ -62,6 +62,15 @@ class ColorBlock(object):
|
|||
"""Number of stitches in this color block."""
|
||||
return len(self.stitches)
|
||||
|
||||
@property
|
||||
def estimated_thread(self):
|
||||
previous_stitch = self.stitches[0]
|
||||
length = 0
|
||||
for stitch in self.stitches[1:]:
|
||||
length += (stitch - previous_stitch).length()
|
||||
previous_stitch = stitch
|
||||
return length
|
||||
|
||||
@property
|
||||
def num_trims(self):
|
||||
"""Number of trims in this color block."""
|
||||
|
|
|
@ -113,7 +113,8 @@ class StitchPlan(object):
|
|||
num_stops=self.num_stops,
|
||||
num_trims=self.num_trims,
|
||||
num_stitches=self.num_stitches,
|
||||
bounding_box=self.bounding_box
|
||||
bounding_box=self.bounding_box,
|
||||
estimated_thread=self.estimated_thread
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -147,6 +148,11 @@ class StitchPlan(object):
|
|||
|
||||
return minx, miny, maxx, maxy
|
||||
|
||||
@property
|
||||
def estimated_thread(self):
|
||||
thread_meter = sum(block.estimated_thread for block in self) / PIXELS_PER_MM / 1000
|
||||
return round(thread_meter, 2)
|
||||
|
||||
@property
|
||||
def dimensions(self):
|
||||
minx, miny, maxx, maxy = self.bounding_box
|
||||
|
|
|
@ -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});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Ładowanie…
Reference in New Issue