On Tue, Aug 27, 2013 at 7:06 PM, mathog <mathog@...1176...> wrote:
On 27-Aug-2013 14:20, Johan Engelen wrote:
> I think we should be able to change this code to
>     p0 = Inkscape::convert_unit(p0,"px",  "in");

Or use a method instead of a function?  The old way where conversions
done by multiplying by PX_PER_IN and friends was C like,  the one above
is about
half way between C and C++.  Wouldn't all the way to an object oriented
style be:

   p0 = p0.in2px();


   p0 = p0.px2in();

It seems like halfway between C and C++ because it is. That syntax is used in older parts of the code that don't use the new Quantity class objects that store values with their units. Where Quantities are used [1], the syntax is:


if one wanted the value in inches, no matter what unit the quantity was in. This syntax doesn't work with older sections of code without extensive rewrites, as the older sections store everything as regular floating point numbers, not objects.


[1] an example: http://bazaar.launchpad.net/~matthewpetroff/inkscape/gsoc-2013-unit-improvement/view/12478/src/extension/internal/latex-pstricks.cpp#L120