Skip to content

Commit c72b92d

Browse files
authored
Merge pull request #16 from mrbeam/rc/0.11.0b0
Revert "SW-1155 g code files created via pixel based images sv gs eng…
2 parents b561835 + 679a261 commit c72b92d

File tree

3 files changed

+24
-56
lines changed

3 files changed

+24
-56
lines changed

octoprint_mrbeam/static/js/render_fills.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,10 @@ Snap.plugin(function (Snap, Element, Paper, global) {
127127
let rasterEl = marked[i];
128128
let bbox;
129129
try {
130-
bbox = rasterEl.get_total_bbox();
131-
} catch (error) {
132-
console.warn(
133-
`Getting bounding box for ${rasterEl} failed.`,
134-
error
135-
);
130+
bbox = rasterEl.get_total_bbox();
131+
}
132+
catch(error) {
133+
console.warn(`Getting bounding box for ${rasterEl} failed.`, error);
136134
continue;
137135
}
138136
// find overlaps
@@ -174,14 +172,13 @@ Snap.plugin(function (Snap, Element, Paper, global) {
174172
rasterEl.addClass(`rasterCluster${c}`)
175173
);
176174
let tmpSvg = svg.clone();
177-
tmpSvg.selectAll(`.toRaster:not(.rasterCluster${c})`).remove();
178-
// tmpSvg.selectAll(`.toRaster:not(.rasterCluster${c})`).forEach((element) => {
179-
// let elementToBeRemoved = tmpSvg.select('#' + element.attr('id'));
180-
// let elementsToBeExcluded = ["text", "tspan"]
181-
// if (elementToBeRemoved && !elementsToBeExcluded.includes(elementToBeRemoved.type)) {
182-
// elementToBeRemoved.remove();
183-
// }
184-
// });
175+
tmpSvg.selectAll(`.toRaster:not(.rasterCluster${c})`).forEach((element) => {
176+
let elementToBeRemoved = tmpSvg.select('#' + element.attr('id'));
177+
let elementsToBeExcluded = ["text", "tspan"]
178+
if (elementToBeRemoved && !elementsToBeExcluded.includes(elementToBeRemoved.type)) {
179+
elementToBeRemoved.remove();
180+
}
181+
});
185182
// Fix IDs of filter references, those are not cloned correct (probably because reference is in style="..." definition)
186183
tmpSvg.fixIds("defs filter[mb\\:id]", "mb:id"); // namespace attribute selectors syntax: [ns\\:attrname]
187184
// DON'T fix IDs of textPath references, they're cloned correct.
@@ -338,17 +335,10 @@ Snap.plugin(function (Snap, Element, Paper, global) {
338335
// );
339336
}
340337

341-
// only enlarge on fonts, images not necessary.
342-
const doEnlargeBBox =
343-
elem.selectAll("text").filter((e) => {
344-
const bb = e.getBBox();
345-
// this filter is required, as every quick text creates an empty text element (for switching between curved and straight text)
346-
return bb.width > 0 && bb.height > 0;
347-
}).length > 0;
348-
349-
// Quick fix: in some browsers the bbox is too tight, so we just add an extra margin to all the sides, making the height and width larger in total
350-
const enlargement_x = doEnlargeBBox ? 0.4 : 0; // percentage of the width added to each side
351-
const enlargement_y = doEnlargeBBox ? 0.4 : 0; // percentage of the height added to each side
338+
// TODO only enlarge on images and fonts
339+
// Quick fix: in some browsers the bbox is too tight, so we just add an extra 10% to all the sides, making the height and width 20% larger in total
340+
const enlargement_x = 0.4; // percentage of the width added to each side
341+
const enlargement_y = 0.4; // percentage of the height added to each side
352342
const x1 = Math.max(0, bbox.x - bbox.width * enlargement_x);
353343
const x2 = Math.min(wMM, bbox.x2 + bbox.width * enlargement_x);
354344
const w = x2 - x1;

octoprint_mrbeam/static/js/snap_helpers.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,4 @@ Snap.plugin(function (Snap, Element, Paper, global) {
6666
const bb = el.getBBox();
6767
return Snap.path.getBBoxWithTransformation(bb, mat);
6868
};
69-
70-
/**
71-
* filter method for Snap Set like we know it from Array
72-
* @param f function which decides wether to keep or discard set elements
73-
* @returns {Set<any>} a new Snap set
74-
*/
75-
Snap.Set.prototype.filter = function (f) {
76-
const s = new Snap.Set();
77-
this.forEach((e) => {
78-
if (f(e)) {
79-
s.push(e);
80-
}
81-
});
82-
return s;
83-
};
8469
});

octoprint_mrbeam/static/js/working_area.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,23 +1201,16 @@ $(function () {
12011201
if (generator.generator === "inkscape") {
12021202
let isOldInkscapeVersion = NaN;
12031203
try {
1204-
isOldInkscapeVersion =
1205-
window.compareVersions(
1206-
// 1.1.2 (1:1.1+202202050950+0a00cf5339) -> 1.1
1207-
generator.version
1208-
.split(".")
1209-
.slice(0, 2)
1210-
.join("."),
1211-
"0.91"
1212-
) <= 0;
1213-
} catch (e) {
1204+
isOldInkscapeVersion= window.compareVersions(
1205+
// 1.1.2 (1:1.1+202202050950+0a00cf5339) -> 1.1
1206+
generator.version.split('.').slice(0,2).join('.'),
1207+
"0.91"
1208+
) <= 0;
1209+
} catch(e) {
12141210
let payload = {
12151211
error: e.message,
12161212
};
1217-
self._sendAnalytics(
1218-
"inkscape_version_comparison_error",
1219-
payload
1220-
);
1213+
self._sendAnalytics("inkscape_version_comparison_error", payload);
12211214
console.log("inkscape_version_comparison_error: ", e);
12221215
// In case the comparison fails, we assume the version to be above 0.91
12231216
// This assumption (the scaling) does not have a major impact as it has
@@ -1722,7 +1715,7 @@ $(function () {
17221715
} else if (
17231716
event.target.classList.contains("unit_percent")
17241717
) {
1725-
let newWidth =
1718+
const newWidth =
17261719
((currentWidth / Math.abs(currentSx)) * value) /
17271720
100.0;
17281721
if (Math.abs(newWidth) < 0.1)
@@ -1766,7 +1759,7 @@ $(function () {
17661759
} else if (
17671760
event.target.classList.contains("unit_percent")
17681761
) {
1769-
let newHeight =
1762+
const newHeight =
17701763
((currentHeight / Math.abs(currentSy)) * value) /
17711764
100.0;
17721765
if (Math.abs(newHeight) < 0.1)

0 commit comments

Comments
 (0)