Difference between revisions of "ViewBoxToDo"
(svn commit rev20339) |
(real world unit blueprint link added) |
||
Line 46: | Line 46: | ||
=== Related === | === Related === | ||
* [http://wiki.inkscape.org/wiki/index.php/BlueprintRealUnit Blueprint for real world unit (mm,in)] | |||
* [https://bugs.launchpad.net/inkscape/+bug/167682 Bug #167682 (resizing page must also resize viewBox)] | * [https://bugs.launchpad.net/inkscape/+bug/167682 Bug #167682 (resizing page must also resize viewBox)] | ||
* [https://launchpad.net/+search?field.text=viewbox Bug search for "viewBox"] | * [https://launchpad.net/+search?field.text=viewbox Bug search for "viewBox"] |
Revision as of 19:05, 9 December 2008
This is an analysis of problems and possible solutions related incomplete viewBox support in inkscape.
Update
I committed the following changes with revision 20339:
- assigning each new element the inversed full parent transform up to desktop, like suggested below in problem description
- dropped sp_desktop_dt2root_* functions and introduced instead:
Geom::Matrix const sp_desktop_dt2doc_affine (SPDesktop const *dt); Geom::Point sp_desktop_dt2doc_xy_point(SPDesktop const *dt, Geom::Point const p);
Recent Problem Description
The viewBox attribute is like an additional transform to the documents root element. Inkscape does render documents with viewBox correct, but most tools currently lack to evaluate the viewBox when creating new elements on canvas. More precisely, neither viewBox nor the root's transform attribute is considered. Unexpected effects are for example:
- pasted elements appear to big
- strokes and other css are to large
- font size to big (fixed with workaround in svn revision 20284)
Also, Inkscape may want to set the viewBox itself to prevent other viewers from showing documents at a higher or lower resolution.
Most tools (in *-context.cpp files) set the transform for some new element to the inverse of the parent transform up to current root, but excluding the root transform:
item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
The full transform could be obtained like this for example:
item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse();
Unfortunately, this cannot be simply replaced, because position coordinates get scaled as well. Position from mouse pointer is retrieved like this:
Geom::Point dtp = desktop->w2d(Geom::Point(event->button.x, event->button.y)); tc->pdoc = sp_desktop_dt2root_xy_point(desktop, dtp);
which finally does consider the root's viewBox attribute further down in desktop-affine.cpp
Geom::Matrix const sp_desktop_root2dt_affine (SPDesktop const *dt) { SPRoot const *root = SP_ROOT(SP_DOCUMENT_ROOT(dt->doc())); return root->c2p * dt->doc2dt(); }
Dropping the viewBox (factor root->c2p) here, and taking the full transform for the new item above might improve the situation.