On Tue, 06 Nov 2012 09:51:03 +0100 Jasper van de Gronde <th.v.d.gronde@...528...> wrote:
What Inkscape should do, is allow setting (either implicitly or explicitly) both the width/height and(!) the viewBox. I actually started out implementing this in the document preferences dialog, with default settings that essentially gave sensible correspondences between pixels and the units used for the document size. However, it turns out that Inkscape essentially has three not completely compatible concepts of units.
Having said that, maybe there is still a way to do this, so feel free to try implementing setting viewBox along with the document size (or some such scheme).
Please see my recent post on exactly this issue:
http://sourceforge.net/mailarchive/forum.php?thread_name=20121104003312.162f...
There is a much better solution, which is illustrated by the attached image "scale.png". This is intended as an addition to the current "Document Properties/Page" config window. It specifies the scale at which the drawing will be displayed on the physical screen, as a ratio between real dimensions on the screen, and the declared dimensions of the drawing.
It seems rather silly that for some purposes, the unit definitions would be read at runtime from a config file, while for other purposes, they would be compiled into the program binary, but that appears to be how it currently works.
And if anyone feels like tackling the units system, here are the main files to look:
src/sp-metric* src/helper/unit* src/util/unit*
I still might have some code lying around that removes most of sp-metric, so this could serve as a start.
I don't understand why there should be specific code to handle metric units. Surely the simplest thing to do is have the ratios between various real-world units defined in the "units.txt" file, and then have the "Default units" option from the "Document Properties/Page" dialog specify which one of those will be considered equivalent to "px" for purposes of that document.
Systems of related units, with integer ratios between them, such as inch/foot/yard/mile, and um/mm/cm/m/km, could be treated as a special case. Then specifying the ratio between any pair of them, such as 1.0 inch = 0.0254 metre , also determines all the other ratios. Having all such units specified in a config file eliminates the need for code changes when somebody wants to introduce new ones.
-- Ian Bruce