Difference between revisions of "ViewBoxToDo"

From Inkscape Wiki
Jump to navigation Jump to search
(preserveAspcetRation)
(cleanup)
Line 1: Line 1:
This is an analysis of problems and possible solutions related incomplete viewBox support in inkscape.
This is an analysis of problems and possible solutions related incomplete viewBox support in inkscape.


=== Update #2 ===
=== Current Status ===


There was a nasty pointer fault in preserveAspcetRation parsing code.
All viewBox related transformation stuff works! :-)


-            if (e) {
=== To Be Done ===
+            if (*e) {


So [https://bugs.launchpad.net/inkscape/+bug/166885 bug #166885] should be fixed as well now.
* Clipping at viewBox boundaries
 
* UI dialog for modifying viewBox
=== 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);
 
=== Former 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.


=== Related ===
=== Related ===


* [http://wiki.inkscape.org/wiki/index.php/BlueprintRealUnit Blueprint for real world unit (mm,in)]
* [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/+bugs?field.searchtext=viewBox Bug search for "viewBox"]
* [https://launchpad.net/+search?field.text=viewbox Bug search for "viewBox"]

Revision as of 18:29, 13 March 2009

This is an analysis of problems and possible solutions related incomplete viewBox support in inkscape.

Current Status

All viewBox related transformation stuff works! :-)

To Be Done

  • Clipping at viewBox boundaries
  • UI dialog for modifying viewBox

Related