translations of groups are not converted to new units when changing document units

Bug #1369197 reported by Alvin Penner on 2014-09-14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Alvin Penner

Bug Description

This is not exactly a bug report, more of a wish list item, but it does have some significant programming implications. When converting document units one would expect that not only would the coordinates of child objects like <path> elements be converted into the new units, but also that any translations on the parent groups would also be converted at the same time. Not that there is any mathematical reason for doing so, but simply for the sake of ease of interpretation.

Attached is a svg file (file line100_px.svg) with a path with a parent group with a translation. The relevant part is:

      d="M 100,100 200,200"

Since both the group and the object start point have coordinates of (100, 100) px, therefore the top left start point is at (200, 200) px.
After converting to mm one would therefore expect the following:

      d="M 28.22,28.22 56.44,56.44"

Alvin Penner (apenner) wrote :
Alvin Penner (apenner) wrote :

Instead one gets (file line100_mm.svg) with the excerpt:

      d="m -43.555547,-43.555554 28.222223,28.222223"

Note that the final result is correct, so there is nothing mathematically wrong with this result. The final coordinates of the start point of the line are 100mm - 43.5555mm = 56.4444mm, which is equivalent to 200px as expected.

However the intermediate results are unexpected. The group translation is now 100mm when we expected 28.22mm. The actual numerical coordinates of the start (x,y) in the <path> element are negative (-43.555) instead of positive, which makes it very difficult to interpret.

This will also complicate things when trying to solve problems like Bug 1287288. This involves groups which may have translations in the <group> element, and which also have clips or masks attached to them. The clip or mask is applied relative to the object before the translations are applied. This means that if the translate property of the group is not converted as expected then the origin of the clip will also be correspondingly wrong, which represents a serious complication in the case of multiple nested groups.

su_v (suv-lp) on 2014-09-14
tags: added: groups transformations units
Changed in inkscape:
importance: Undecided → Wishlist
milestone: none → 0.91
su_v (suv-lp) on 2014-09-21
Changed in inkscape:
status: New → Confirmed
su_v (suv-lp) on 2014-11-06
Changed in inkscape:
importance: Wishlist → Medium
milestone: 0.91 → 0.92
Johan Engelen (johanengelen) wrote :

Changing to wishlist item, and removing milestone.

The basic request here is: allow changing of the unit of the values in SVG. This is not possible yet (hence wishlist), and is hard and will probably not be implemented soon (removing milestone).

Changed in inkscape:
importance: Medium → Wishlist
milestone: 0.92 → none
su_v (suv-lp) wrote :

On 2014-12-01 20:15 (+0100), Johan Engelen wrote:
> The basic request here is: allow changing of the unit of the values in
> SVG. This is not possible yet (hence wishlist), and is hard and will
> probably not be implemented soon (removing milestone).

Just for the record (in case developers revisiting this report later on might be confused by the status changes): the feature to change "the unit of the values in SVG" existed during a certain time in the development period between 0.48 and 0.91 (after the merge of the gsoc-2013-unit-improvement branch), but was backed out in r13748.

Alvin Penner (apenner) wrote :

fix committed to rev 13926.

In order to test this code, it will be necessary to re-enable the use of the routine scaleChildItemsRec, which is normally executed during a change of document units. This routine was temporarily disabled in rev 13748.

The simplest way to re-enable the code to execute normally is to comment out line 1714 of src\ui\dialog\document-properties.cpp, which currently reads:
#if 0
Change it to read //#if 0 or delete it.

Similarly, comment out line 1766, which currently reads:
Change it to read //#endif or delete it.

Changed in inkscape:
status: Confirmed → Fix Committed
assignee: nobody → Alvin Penner (apenner)
su_v (suv-lp) on 2015-05-09
Changed in inkscape:
milestone: none → 0.92
Bryce Harrington (bryce) on 2017-01-10
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers