Difference between revisions of "ViewBoxToDo"

From Inkscape Wiki
Jump to navigation Jump to search
(svn commit rev20339)
(import/export done)
 
(6 intermediate revisions by 2 users not shown)
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 to incomplete viewBox support in inkscape.


=== Update ===
=== To Be Done ===


I committed the following changes with revision 20339:
* Clipping at viewBox boundaries
 
* UI dialog for modifying viewBox
* 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.


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


* [https://bugs.launchpad.net/inkscape/+bug/167682 Bug #167682 (resizing page must also resize viewBox)]
* [http://wiki.inkscape.org/wiki/index.php/BlueprintRealUnit Blueprint for real world unit (mm,in)]
* [https://launchpad.net/+search?field.text=viewbox Bug search for "viewBox"]
* [https://bugs.launchpad.net/inkscape/+bugs?field.searchtext=viewBox Bug search for "viewBox"]

Latest revision as of 20:21, 15 May 2009

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

To Be Done

  • Clipping at viewBox boundaries
  • UI dialog for modifying viewBox

Related