r03ert0 / microdraw

Collaborative vectorial annotation tool for ultra high resolution data.
http://microdraw.pasteur.fr
GNU General Public License v3.0
42 stars 41 forks source link

Paper.js API Breaking Changes #52

Closed dephora closed 7 years ago

dephora commented 7 years ago

First, great library.

In the interest of keeping it in line with newer versions of Paper.js I'll document breaking changes if there is a desire to upgrade (or for those who want to use the more recent versions of Paper.js). This will be a running list as I haven't yet tested everything.

Currently testing on Paper 0.11.4 / OpenSeadragon 2.2.1

Undo breaks immediately.

function applyUndo(undo) {
    if( undo.imageNumber !== currentImage )
        setImage(undo.imageNumber);
    var info = ImageInfo[undo.imageNumber]["Regions"];
    while( info.length > 0 )
        removeRegion(info[0], undo.imageNumber);
    region = null;
    for( var i = 0; i < undo.regions.length; i++ ) {
        var el = undo.regions[i];
        var project = paper.projects[ImageInfo[undo.imageNumber]["projectID"]];
        /* Create the path and add it to a specific project.
         */
        var path = new paper.Path();
/*1106*/    project.addChild(path);   // <====== Breaking ======>
        path.importJSON(el.json);
        reg = newRegion({name:el.name, path:path}, undo.imageNumber);
        // here order matters. if fully selected is set after selected, partially selected paths will be incorrect
        reg.path.fullySelected = el.fullySelected;
        reg.path.selected = el.selected;
        if( el.selected ) {
            if( region === null )
                region = reg;
            else
                console.log("Should not happen: two regions selected?");
        }
    }
    drawingPolygonFlag = undo.drawingPolygonFlag;
}
// line 1106
project.addChild(path);
Paper.js

https://github.com/paperjs/paper.js/blob/develop/CHANGELOG.md (V 0.10.0) Undocumented function Project#addChild() that added a layer to a project. It is replaced by Project#addLayer() and Project#insertLayer().

r03ert0 commented 7 years ago

Hi @dephora! Thank you for the bug report! Thanks to the link you provided the bug was very easy to fix : ) (in the branch update-paperjs). I'll check if there are some other bugs and merge with the node-express branch (which moves away from mysql/php into mongo/express)

r03ert0 commented 7 years ago

update to paperjs 2.3.1 breaks 'addPoint' function

r03ert0 commented 7 years ago

I was able to track the problem in the addPoint function to a bug in paperjs, reported as issue #1392 (https://github.com/paperjs/paper.js/issues/1392)

r03ert0 commented 7 years ago

Commit 084955b adds a workaround this issue: the insert function is kept in a temporary variable, and injected back to path after importJSON was invoked.