Difference between revisions of "ViewBoxToDo"
(created) |
|||
Line 7: | Line 7: | ||
* font size to big (fixed with workaround in svn revision 20284) | * font size to big (fixed with workaround in svn revision 20284) | ||
Most tools (in *-context.cpp files) set the transform for some new element to the | 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()); | item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); |
Revision as of 08:08, 3 December 2008
This is an analysis of problems and possible solutions related incomplete viewBox support in inkscape.
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.