WIP show text after upload in svg.

missing:
- add warning/dialogue about text in conversion dialogue
- cleanup
This commit is contained in:
clemniem 2016-06-21 15:13:36 +02:00
parent 6641390620
commit aad5efff2d
3 changed files with 33 additions and 31 deletions

View file

@ -44,7 +44,7 @@ Snap.plugin(function (Snap, Element, Paper, global) {
var child = children[i];
child.bake(toCubics, dec);
}
elem.attr({transform: ''});
if(child.type !== "#text") elem.attr({transform: ''});
return;
}
if (elem.type !== "circle" &&

View file

@ -274,10 +274,10 @@ $(function(){
newSvgAttrs['transform'] = scaleMatrixStr;
var newSvg = snap.group(f.selectAll("svg>*"));
var hasText = newSvg.selectAll('text,tspan');
if(hasText !== null && hasText.length > 0){
self.svg_contains_text_warning(newSvg);
}
// var hasText = newSvg.selectAll('text,tspan');
// if(hasText !== null && hasText.length > 0){
// self.svg_contains_text_warning(newSvg);
// }
newSvg.bake(); // remove transforms
newSvg.selectAll('path').attr({strokeWidth: '0.5'});
@ -397,15 +397,15 @@ $(function(){
};
self.svg_contains_text_warning = function(svg){
var error = "<p>" + gettext("The svg file contains text elements.<br/>Please convert them to paths.<br/>Otherwise they will be ignored.") + "</p>";
//error += pnotifyAdditionalInfo("<pre>" + data.jqXHR.responseText + "</pre>");
new PNotify({
title: "Text elements found",
text: error,
type: "warn",
hide: false
});
svg.selectAll('text,tspan').remove();
// var error = "<p>" + gettext("The svg file contains text elements.<br/>Please convert them to paths.<br/>Otherwise they will be ignored.") + "</p>";
// //error += pnotifyAdditionalInfo("<pre>" + data.jqXHR.responseText + "</pre>");
// new PNotify({
// title: "Text elements found",
// text: error,
// type: "warn",
// hide: false
// });
// svg.selectAll('text,tspan').remove();
};
self.svg_misfitting_warning = function(svg, misfitting){

View file

@ -18,7 +18,7 @@
</div>
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Sets the intensity of the laser. The more intensity the deeper the effect on the material.
Sets the intensity of the laser. The more intensity the deeper the effect on the material.
Cutting needs higher intensities than engraving.
The effect in general is dependent from the material and its color and surface.
</div>
@ -33,14 +33,16 @@
</div>
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Sets the velocity of the laser head. The slower the movement the deeper the effect on the material.
Cutting needs slower movement than engraving.
Sets the velocity of the laser head. The slower the movement the deeper the effect on the material.
Cutting needs slower movement than engraving.
The effect in general is dependent from the material and its color and surface.
</div>
</div>
<label class="control-label">{{ _('Filled areas') }}</label>
<div class="controls">
<label class="checkbox">
{#TODO: CLEM make checkbox usable fill_text #}
<input type="checkbox" data-bind="checked: fill_text">{{ _('Engrave Text') }}
<input type="checkbox" data-bind="checked: fill_areas">{{ _('Engrave Infills') }}
</label>
</div>
@ -56,11 +58,11 @@
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Some (especially bright) materials require the laser to dwell a little until the surface has absorbed enough energy to be affected.
This parameter sets the amount of time in milliseconds the movement is paused after the laser is switched on.
This parameter sets the amount of time in milliseconds the movement is paused after the laser is switched on.
If the result shows gaps in lines for example increase this value carefully. The higher the value the higher the risk of material ignition.
</div>
</div>
<div data-bind="visible: show_image_parameters ">
<p>{{ _('Image engraving parameters:') }}</p>
<div class="control-group" >
@ -103,10 +105,10 @@
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Pixel / raster engravings are done line by line. This sets the distance between the single lines.
Smaller values allow finer engravings but require a more precise focus and are slower.
Smaller values allow finer engravings but require a more precise focus and are slower.
</div>
<p >{{ _('Image Preprocessing') }}</p>
<div class="controls">
<div class="img_preprocessing_preview before" style="background-image:url(/plugin/svgtogcode/static/img/kitty_grayscale.png);" >before</div>
@ -114,22 +116,22 @@
<div class="img_preprocessing_preview contrast" style="background-image:url(/plugin/svgtogcode/static/img/kitty_contrast.png);" data-bind="style: { opacity: contrastPreview }" ></div>
<div class="img_preprocessing_preview sharpened" style="background-image:url(/plugin/svgtogcode/static/img/kitty_sharpened.png);" data-bind="style: { opacity: sharpenedPreview }" ></div>
<div class="img_preprocessing_preview dithered" style="background-image:url(/plugin/svgtogcode/static/img/kitty_dithered_150.png);" data-bind="visible: imgDithering"></div>
</div>
<div class="photo_attribution"><a href="http://www.christianholmer.com" target="_blank">Photo: Christian Holmér</a></div>
</div>
<div data-bind="disable:imgDithering ">
<label class="control-label">{{ _('Contrast') }}</label>
<div class="controls img_slider">
<input id="svgtogcode_contrast_slider" type="text" data-bind="value: imgContrast" >
</div>
<div style="clear:both"></div>
<div style="clear:both"></div>
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Increases the image contrast before converting to gcode.
Increases the image contrast before converting to gcode.
</div>
<label class="control-label">{{ _('Sharpening') }}</label>
<div class="controls img_slider">
<input id="svgtogcode_sharpening_slider" class="uninitialized" type="text" data-bind="value: imgSharpening">
@ -137,10 +139,10 @@
<div style="clear:both"></div>
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Sharpens the image before converting to gcode.
Sharpens the image before converting to gcode.
</div>
</div>
<label class="control-label">{{ _('Dithering') }}</label>
<div class="controls">
<label class="checkbox">
@ -149,8 +151,8 @@
</div>
<div class="controls alert alert-info hint" data-bind="visible: showHints">
<span class="icon icon-question-sign" aria-hidden="true"></span>
Converts the image to solely black and white pixels.
Use this if the laser effect on your material is not able to transfer grayscales.
Converts the image to solely black and white pixels.
Use this if the laser effect on your material is not able to transfer grayscales.
</div>
</div>
@ -185,4 +187,4 @@
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true" data-bind="click: $root.cancel_conversion()">{{ _('Cancel') }}</a>
<a href="#" class="btn btn-primary" data-bind="click: function() { if ($root.enableConvertButton()) { $root.convert() } }, enabled: enableConvertButton, css: {disabled: !$root.enableConvertButton()}">{{ _('Convert') }}</a>
</div>
</div>
</div>