Repeating rounding errors with svg:viewBox, svg:d & friends

Friedrich W. H. Kossebau kossebau at kde.org
Sat Jul 7 23:29:28 BST 2012


Hi,

is anyone currently looking into improving graph data handling?

Because things are slightly screwed there IMHO.

E.g. I was trying to fix EnhancedPathShape::saveOdf(...), which is currently 
saving non-integer data for "svg:viewBox", by code like

        context.xmlWriter().addAttribute("svg:viewBox", QString("%1 %2 %3 
%4").arg(m_viewBox.x()).arg(m_viewBox.y()).arg(m_viewBox.width()).arg(m_viewBox.height()));

with m_viewBox being a QRectF (uh :) , only integer data is allowed in 
"svg:viewBox", as you surely know).

When looking at KoPathShape as reference all the qRound there looked 
suspicious, so I tested if and how the data changes on a few roundtrips. And 
it does, see attached file. Not sure how grave those changes are, but I would 
feel better if the data stays exactly the same. Someone agrees?

I would give it a try to get there if noone else it already retwisting those 
codelines with a similar goal.

Cheers
Friedrich
-------------- next part --------------
1. save:
    <draw:path draw:style-name="gr1" xml:id="shape-1" draw:id="shape-1" draw:layer="" svg:width="126.83027781338pt" svg:height="89.88699631360pt" svg:x="205.60859236268pt" svg:y="167.49836198253pt" svg:viewBox="0 0 127 90" svg:d="M80.7533 67.911C52.1956 96.5166 -17.247 70.1188 3.96603 27.6217C19.6091 -3.71699 40.7153 0.151678 75.2684 0.151678C88.7736 0.151678 116.736 2.64726 122.804 14.8023C143.807 56.88 77.3285 89.887 46.0161 89.887" calligra:nodeTypes="ccccc"/>

2. load and save:
    <draw:path draw:style-name="gr1" xml:id="shape-1" draw:id="shape-1" draw:layer="" svg:width="126.66095607404pt" svg:height="89.77413854538pt" svg:x="205.60859236268pt" svg:y="167.49836198253pt" svg:viewBox="0 0 127 90" svg:d="M80.6454 67.8257C52.1258 96.3954 -17.224 70.0308 3.96072 27.587C19.5829 -3.71232 40.6609 0.151488 75.1678 0.151488C88.655 0.151488 116.58 2.64394 122.64 14.7837C143.615 56.8086 77.2251 89.7741 45.9546 89.7741" calligra:nodeTypes="ccccc"/>

3. load and save:
    <draw:path draw:style-name="gr1" xml:id="shape-1" draw:id="shape-1" draw:layer="" svg:width="126.32296657520pt" svg:height="89.54880526942pt" svg:x="205.60859236268pt" svg:y="167.49836198253pt" svg:viewBox="0 0 126 90" svg:d="M80.4301 67.6555C51.9867 96.1535 -17.178 69.8551 3.95016 27.5178C19.5306 -3.703 40.5524 0.151108 74.9671 0.151108C88.4183 0.151108 116.269 2.6373 122.313 14.7466C143.232 56.666 77.0189 89.5488 45.8319 89.5488" calligra:nodeTypes="ccccc"/>


More information about the calligra-devel mailing list