letsfindaway / OpenBoard

I'm using this fork to contribute features and fixes to the upstream project. In order to create good pull requests, I'm rebasing my feature branches, squashing and reordering commits, etc. If you fork this repository be aware that my development branches may rewrite history without prior notice.
http://openboard.ch/
GNU General Public License v3.0
9 stars 0 forks source link

Serialization of an arc #136

Closed letsfindaway closed 1 year ago

letsfindaway commented 1 year ago

The handling of OBGraphicsStroke and OBGraphicsStrokesGroup seems to be inconsistent somewhere. I can demonstrate that with a simple document with an arc drawn by the compass tool.

After drawing the arc and removing the compass tool, the SVG looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ub="http://uniboard.mnemis.com/document" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.1" ub:version="4.8.0" ub:uuid="6928ab7a-8ab5-432b-98a1-f4b3cb2b81a7" viewBox="-690 -530 1380 1060" ub:nominal-size="1280x960" ub:dark-background="false" ub:crossed-background="false" ub:ruled-background="false" ub:grid-size="33" pageDpi="96">
    <rect fill="white" x="-690" y="-530" width="1380" height="1060"/>
    <g ub:z-value="-999999" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="ea7700c0-4efa-4754-9830-c5e9370baf67" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="126.889,-4.44444 126.649,-16.4907 125.934,-28.4148 124.754,-40.2077 123.117,-51.8603 121.034,-63.3633 118.512,-74.7077 112.192,-96.8841 104.23,-118.316 94.6982,-138.931 83.6706,-158.656 71.22,-177.417 71.2072,-177.397 70.5395,-179.471 70.8189,-180.855 71.5809,-181.985 72.7111,-182.747 74.0951,-183.027 75.743,-182.623 76.9829,-181.546 76.9957,-181.567 89.7454,-162.354 101.038,-142.155 110.798,-121.045 118.951,-99.0989 125.423,-76.3909 128.005,-64.7746 130.138,-52.996 131.814,-41.0643 133.022,-28.9889 133.754,-16.7792 134,-4.44444 133.721,-3.06046 132.959,-1.93029 131.828,-1.1683 130.444,-0.888889 129.06,-1.1683 127.93,-1.93029 127.168,-3.06046 126.889,-4.44444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="winding" ub:uuid="d4498375-d2e8-4dd0-bf64-41707fb25c92" ub:parent="ea7700c0-4efa-4754-9830-c5e9370baf67"/>
        <polygon points="-169.056,-9.44444 -169.056,0.555556 -169.202,0.909109 -169.361,1.01626 -169.556,1.05556 -169.909,0.909109 -170.016,0.750178 -170.056,0.555556 -170.056,-9.44444 -169.909,-9.798 -169.75,-9.90515 -169.556,-9.94444 -169.202,-9.798 -169.095,-9.63907 -169.056,-9.44444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="ebe33db1-4e72-4f92-b6fe-329f0c803b55" ub:parent="ea7700c0-4efa-4754-9830-c5e9370baf67"/>
        <polygon points="-174.556,-4.94444 -164.556,-4.94444 -164.202,-4.798 -164.095,-4.63907 -164.056,-4.44444 -164.202,-4.09089 -164.361,-3.98374 -164.556,-3.94444 -174.556,-3.94444 -174.909,-4.09089 -175.016,-4.24982 -175.056,-4.44444 -174.909,-4.798 -174.75,-4.90515 -174.556,-4.94444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="26a06783-3ff8-45b7-a095-3237393f220c" ub:parent="ea7700c0-4efa-4754-9830-c5e9370baf67"/>
    </g>
    <line x1="-169.56" y1="-9.44" x2="-169.56" y2="0.56" stroke-width="1.000000" stroke="#004080" stroke-linecap="round" ub:z-value="3" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080"/>
    <line x1="-174.56" y1="-4.44" x2="-164.56" y2="-4.44" stroke-width="1.000000" stroke="#004080" stroke-linecap="round" ub:z-value="4" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080"/>
</svg>

The first polygon is the arc, the two others the center cross. The center cross is duplicated in two <line> elements. I would have expected that the <g> contains a polygon and two lines. The external line elements are not required and in fact they have no correlation to the group in any way.

Close and reopen the document

Then close and reopen the document. Make a change and undo it again, to make the document dirty. Then save it again. The result:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ub="http://uniboard.mnemis.com/document" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.1" ub:version="4.8.0" ub:uuid="d347af8a-3bca-4e61-8adf-76ac2b5fe9c1" viewBox="-690 -530 1380 1060" ub:nominal-size="1280x960" ub:dark-background="false" ub:crossed-background="false" ub:ruled-background="false" ub:grid-size="33" pageDpi="96">
    <rect fill="white" x="-690" y="-530" width="1380" height="1060"/>
    <g ub:z-value="-999999" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="69fa03bf-5efa-4ee6-99e2-7d356444b966" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="-174.56,-4.94 -164.56,-4.94 -164.206,-4.79355 -164.099,-4.63462 -164.06,-4.44 -164.206,-4.08645 -164.365,-3.97929 -164.56,-3.94 -174.56,-3.94 -174.914,-4.08645 -175.021,-4.24538 -175.06,-4.44 -174.914,-4.79355 -174.755,-4.90071 -174.56,-4.94 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="e96d3f68-662d-4ed9-bd19-a008561635fc" ub:parent="69fa03bf-5efa-4ee6-99e2-7d356444b966"/>
    </g>
    <g ub:z-value="-999998" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="15298c65-038f-4751-a0a3-c631eba4caca" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="126.889,-4.44444 126.649,-16.4907 125.934,-28.4148 124.754,-40.2077 123.117,-51.8603 121.034,-63.3633 118.512,-74.7077 112.192,-96.8841 104.23,-118.316 94.6982,-138.931 83.6706,-158.656 71.22,-177.417 71.2072,-177.397 70.5395,-179.471 70.8189,-180.855 71.5809,-181.985 72.7111,-182.747 74.0951,-183.027 75.743,-182.623 76.9829,-181.546 76.9957,-181.567 89.7454,-162.354 101.038,-142.155 110.798,-121.045 118.951,-99.0989 125.423,-76.3909 128.005,-64.7746 130.138,-52.996 131.814,-41.0643 133.022,-28.9889 133.754,-16.7792 134,-4.44444 133.721,-3.06046 132.959,-1.93029 131.828,-1.1683 130.444,-0.888889 129.06,-1.1683 127.93,-1.93029 127.168,-3.06046 126.889,-4.44444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="winding" ub:uuid="65b4fae1-a15a-4bfb-8d79-fc81f262fa4c" ub:parent="15298c65-038f-4751-a0a3-c631eba4caca"/>
        <polygon points="-169.056,-9.44444 -169.056,0.555556 -169.202,0.909109 -169.361,1.01626 -169.556,1.05556 -169.909,0.909109 -170.016,0.750178 -170.056,0.555556 -170.056,-9.44444 -169.909,-9.798 -169.75,-9.90515 -169.556,-9.94444 -169.202,-9.798 -169.095,-9.63907 -169.056,-9.44444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="42ecda4a-5bff-4ae9-a0c1-bb4aa7a4d125" ub:parent="15298c65-038f-4751-a0a3-c631eba4caca"/>
        <polygon points="-174.556,-4.94444 -164.556,-4.94444 -164.202,-4.798 -164.095,-4.63907 -164.056,-4.44444 -164.202,-4.09089 -164.361,-3.98374 -164.556,-3.94444 -174.556,-3.94444 -174.909,-4.09089 -175.016,-4.24982 -175.056,-4.44444 -174.909,-4.798 -174.75,-4.90515 -174.556,-4.94444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="7c641e1c-4c85-499b-8901-29376f085a2b" ub:parent="15298c65-038f-4751-a0a3-c631eba4caca"/>
    </g>
    <g ub:z-value="-999997" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="8ad9f0dc-53dc-4e73-a51d-be055f98637f" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="-169.06,-9.44 -169.06,0.56 -169.206,0.913553 -169.365,1.02071 -169.56,1.06 -169.914,0.913553 -170.021,0.754623 -170.06,0.56 -170.06,-9.44 -169.914,-9.79355 -169.755,-9.90071 -169.56,-9.94 -169.206,-9.79355 -169.099,-9.63462 -169.06,-9.44 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="f58ece7e-f3da-48fb-a941-6f4719bbaed0" ub:parent="8ad9f0dc-53dc-4e73-a51d-be055f98637f"/>
    </g>
    <line x1="-174.56" y1="-4.44" x2="-164.56" y2="-4.44" stroke-width="1.000000" stroke="#004080" stroke-linecap="round" ub:z-value="2" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080"/>
    <line x1="-169.56" y1="-9.44" x2="-169.56" y2="0.56" stroke-width="1.000000" stroke="#004080" stroke-linecap="round" ub:z-value="6" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080"/>
</svg>

Two additional <g> elements are created, each representing the outline of one line of the center cross. I assume these elements are created when parsing the <line> elements, but I have not investigated this further.

Repeat this step

When repeating this step, even more <g> are created:

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ub="http://uniboard.mnemis.com/document" xmlns:xhtml="http://www.w3.org/1999/xhtml" version="1.1" ub:version="4.8.0" ub:uuid="3df6e3d2-062d-4267-9f03-a40fcbb5984a" viewBox="-690 -530 1380 1060" ub:nominal-size="1280x960" ub:dark-background="false" ub:crossed-background="false" ub:ruled-background="false" ub:grid-size="33" pageDpi="96">
    <rect fill="white" x="-690" y="-530" width="1380" height="1060"/>
    <g ub:z-value="-999995" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="73891e7b-38d0-4d75-90aa-df7e5230ca28" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="-169.06,-9.44 -169.06,0.56 -169.206,0.913553 -169.365,1.02071 -169.56,1.06 -169.914,0.913553 -170.021,0.754623 -170.06,0.56 -170.06,-9.44 -169.914,-9.79355 -169.755,-9.90071 -169.56,-9.94 -169.206,-9.79355 -169.099,-9.63462 -169.06,-9.44 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="1305787a-ebf0-4445-ae6e-61344b2bb476" ub:parent="73891e7b-38d0-4d75-90aa-df7e5230ca28"/>
    </g>
    <g ub:z-value="-999999" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="8e413647-b0b3-4e7f-a2c8-82902987c7c0" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="126.889,-4.44444 126.649,-16.4907 125.934,-28.4148 124.754,-40.2077 123.117,-51.8603 121.034,-63.3633 118.512,-74.7077 112.192,-96.8841 104.23,-118.316 94.6982,-138.931 83.6706,-158.656 71.22,-177.417 71.2072,-177.397 70.5395,-179.471 70.8189,-180.855 71.5809,-181.985 72.7111,-182.747 74.0951,-183.027 75.743,-182.623 76.9829,-181.546 76.9957,-181.567 89.7454,-162.354 101.038,-142.155 110.798,-121.045 118.951,-99.0989 125.423,-76.3909 128.005,-64.7746 130.138,-52.996 131.814,-41.0643 133.022,-28.9889 133.754,-16.7792 134,-4.44444 133.721,-3.06046 132.959,-1.93029 131.828,-1.1683 130.444,-0.888889 129.06,-1.1683 127.93,-1.93029 127.168,-3.06046 126.889,-4.44444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="winding" ub:uuid="e21b0c8c-e6d6-4fc7-aee2-3dc62f5ce456" ub:parent="8e413647-b0b3-4e7f-a2c8-82902987c7c0"/>
        <polygon points="-169.056,-9.44444 -169.056,0.555556 -169.202,0.909109 -169.361,1.01626 -169.556,1.05556 -169.909,0.909109 -170.016,0.750178 -170.056,0.555556 -170.056,-9.44444 -169.909,-9.798 -169.75,-9.90515 -169.556,-9.94444 -169.202,-9.798 -169.095,-9.63907 -169.056,-9.44444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="c3ca1b71-d9c0-49a8-a031-6b711941a839" ub:parent="8e413647-b0b3-4e7f-a2c8-82902987c7c0"/>
        <polygon points="-174.556,-4.94444 -164.556,-4.94444 -164.202,-4.798 -164.095,-4.63907 -164.056,-4.44444 -164.202,-4.09089 -164.361,-3.98374 -164.556,-3.94444 -174.556,-3.94444 -174.909,-4.09089 -175.016,-4.24982 -175.056,-4.44444 -174.909,-4.798 -174.75,-4.90515 -174.556,-4.94444 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="41d6a54d-62b5-440b-b6e9-d3ce0e56c2a2" ub:parent="8e413647-b0b3-4e7f-a2c8-82902987c7c0"/>
    </g>
    <g ub:z-value="-999998" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="7105273f-c922-47e6-9792-51cc76ae85e0" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="-169.06,-9.44 -169.06,0.56 -169.206,0.913553 -169.365,1.02071 -169.56,1.06 -169.914,0.913553 -170.021,0.754623 -170.06,0.56 -170.06,-9.44 -169.914,-9.79355 -169.755,-9.90071 -169.56,-9.94 -169.206,-9.79355 -169.099,-9.63462 -169.06,-9.44 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="55686b2b-4224-40fb-9795-ea7b2819bb38" ub:parent="7105273f-c922-47e6-9792-51cc76ae85e0"/>
    </g>
    <g ub:z-value="-999997" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="80437ac7-98ad-4203-ae43-07f80091e023" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="-174.56,-4.94 -164.56,-4.94 -164.206,-4.79355 -164.099,-4.63462 -164.06,-4.44 -164.206,-4.08645 -164.365,-3.97929 -164.56,-3.94 -174.56,-3.94 -174.914,-4.08645 -175.021,-4.24538 -175.06,-4.44 -174.914,-4.79355 -174.755,-4.90071 -174.56,-4.94 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="315b6261-d663-4737-900a-c10ecdbe4663" ub:parent="80437ac7-98ad-4203-ae43-07f80091e023"/>
    </g>
    <g ub:z-value="-999996" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080" ub:uuid="cbb93ac4-2730-4df9-99c7-0371499d8791" ub:hidden-on-display="false" ub:layer="-1000">
        <polygon points="-174.56,-4.94 -164.56,-4.94 -164.206,-4.79355 -164.099,-4.63462 -164.06,-4.44 -164.206,-4.08645 -164.365,-3.97929 -164.56,-3.94 -174.56,-3.94 -174.914,-4.08645 -175.021,-4.24538 -175.06,-4.44 -174.914,-4.79355 -174.755,-4.90071 -174.56,-4.94 " transform="matrix(1, 0, 0, 1, 0, 0)" fill="#004080" fill-opacity="1.00" fill-rule="evenodd" ub:uuid="83f19999-8331-4553-8d9d-f7ff776175f7" ub:parent="cbb93ac4-2730-4df9-99c7-0371499d8791"/>
    </g>
    <line x1="-174.56" y1="-4.44" x2="-164.56" y2="-4.44" stroke-width="1.000000" stroke="#004080" stroke-linecap="round" ub:z-value="6" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080"/>
    <line x1="-169.56" y1="-9.44" x2="-169.56" y2="0.56" stroke-width="1.000000" stroke="#004080" stroke-linecap="round" ub:z-value="8" ub:fill-on-dark-background="#66c0ff" ub:fill-on-light-background="#004080"/>
</svg>

It seems that every time I open the document, the <line> elements are duplicated into another <g> element.

Impact

The additional elements are not visible, because the are exactly on top of each other. But when I remove the arc, then the cross remains and I have to delete each line individually or do a rubber band selection to remove them all at once.

letsfindaway commented 1 year ago

The problem is with saving the document. The correct serialization would be something like

<g>
  <polygon/>
  <line/>
  <line/>
</g>
letsfindaway commented 1 year ago

Closing as PR was merged