tell user resizing page must also resize viewBox, if present

Bug #167682 reported by Bug Importer
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Thomas Holder

Bug Description

I edited an SVG document generated with pstoedit from
an eps file (don't know if this matters). I tried "
fit page to selection", and it produced the correct
page dimensions, but the drawing itself gets scaled,
so it ends up smaller than the page.

It seems also to happen when editing the page size

Since I was not able to repoduce it from a blank
sheet, I attached the file that causes the problem.

Tags: ui
Revision history for this message
Bug Importer (bug-importer) wrote :
Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

Was me who submitted that one, forgot to log in, sorry.

By the way, I am using 0.44pre3.

Revision history for this message
Buliabyak-users (buliabyak-users) wrote :

This is caused by viewBox and is correct behavior per SVG
standard. Remove the viewBox attribute if you want to avoid
this scaling, or resize it to the same values as width/height.

Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

Oh, thanks, I had overseen that. Didn't expect pstoedit to
create a viewBox.

Revision history for this message
Rwst (rwst) wrote :

while the issue is resolved for the original submitter, I
guess that telling the user somehow what he must expect
would be good here, either by adding this to the tooltips,
or by giving the user a choice dialog after clicking resize.

Revision history for this message
Emmanuelp (emmanuelp) wrote :

Originator: NO

<i>This is caused by viewBox and is correct behavior per SVG

While I understand that, I think the resulting behaviour of page resizing
when there's a viewBox is broken.
I don't think a tooltip is a good idea, since it would just say: "We know
this feature is broken in case of viewbox. Please fix it by yourself by
removing the viewbox attribute." :)

So I guess it would be a good idea to automatically tweak the viewbox
parameters. But may be there's a good reason to not modify the viewbox ?

Revision history for this message
Bryce Harrington (bryce) wrote :

This sounds like more of a wishlist item, since our current behavior is correct as per the SVG spec.

Can someone summarize what the preferred behavior ought to be here?

Changed in inkscape:
importance: Low → Wishlist
status: New → Incomplete
Revision history for this message
David Eccles (gringer) (gringer) wrote :

This is a bug that has annoyed me a few too many times, so I'll probably have a look at the code to see what I can do. My previous workaround (before I was aware this was a viewbox issue) was the following:
1) Group the selection
2) making a duplicate of the selection
3) cut the duplicate
4) select the original, fit page to selection
5) delete the original, paste the duplicate

Now that I'm aware it's a viewbox issue, the following seems as if it may also work:
1) Remove viewbox attribute
2) fit page to selection

The current behaviour regarding the viewbox seems odd, and I may not have the proper grasp of it, but I'll plod along anyway...

The preferred behaviour for me would be for 'fit page to selection' to fit the apparent page to the selection, rather than resizing the page based on what width the selection is in the context of the viewbox. Let's say the page is (apparently) 'p' units wide, the selection is 's' units wide, and the viewbox has width 'v'. I see three options to do this:
A) change the viewbox width to s/p and the page width to s/p
B) change the *selection* width to p/s
C) remove the viewbox, then change the page width to s/p
Compare this with what seems to be the current behaviour:
D) change the page width to s/p, without modifying the viewbox width

As the user has requested fit *page* to selection, rather than fit selection to page, option A seems like the only reasonable thing to do in this case -- I'm going to assume that the user wants to keep the viewbox.

Revision history for this message
David Eccles (gringer) (gringer) wrote :

Here's a patch that implements option A above. It's a bit rough at the moment:
* Undo doesn't seem to work properly (object appears outside dimensions of page)
* Origin of viewbox doesn't change (except by scaling). Calculating this would probably need to depend on where the viewbox origin was with respect to the object before the resize operation.

Revision history for this message
David Eccles (gringer) (gringer) wrote :
Revision history for this message
MALDATA (malocascio) wrote :

I just ran into this bug. I made a postscript file using gnuplot and opened it in Inkscape. I then tried to do "Fit page to selection," and it shrunk the plot.

The only thing I have to add here is that in this case, deleting the viewbox attribute reduces the size of the plot to about 1 pixel. Here it's easier to just copy the plot, fit page to selection, delete the new shrunken plot, paste the old one in, then align it with the page.

I'm not sure if that's helpful or not, but at least it's more information.

Revision history for this message
David Eccles (gringer) (gringer) wrote :

Could someone please explain why this bug is tagged as incomplete? According to the mapping between bugzilla and launchpad, this happens when the bugzilla tags are NEEDINFO or NEEDINFO_REPORTER or WAITING or SUSPENDED. This bug seems to have sufficient information to work on:

* A well-defined problem... I'll try to summarise: "Fit page to selection" does not fit page to selection when viewbox attribute is present. [I can clarify this further if necessary]
* A test-case that demonstrates the issue
* A patch that (for me) fixes this specific bug

I would expect that the most significant problem I've noticed with my patch (undo not working properly) could be resolved by someone who has an understanding of the Inkscape source code.

Thomas Holder (speleo3)
Changed in inkscape:
assignee: nobody → speleo3
status: Incomplete → In Progress
Revision history for this message
Thomas Holder (speleo3) wrote :

fixed in svn revision 20333

Changed in inkscape:
status: In Progress → Fix Committed
jazzynico (jazzynico)
Changed in inkscape:
milestone: none → 0.47
ScislaC (scislac)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers