cornerstonejs / cornerstoneTools

A framework for tools built on top of Cornerstone.
https://tools.cornerstonejs.org/
MIT License
574 stars 456 forks source link

How to insert new annotation from save json in react? #1557

Open Atp-Gaster opened 8 months ago

Atp-Gaster commented 8 months ago

Prerequisites

Description

This is the example data that come from cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState(); var ExampleData = { "Bidirectional": { "data": [ { "toolName": "Bidirectional", "toolType": "Bidirectional", "isCreating": true, "visible": true, "active": false, "invalidated": false, "handles": { "start": { "x": 317.76188602709806, "y": 234.64989562868368, "index": 0, "drawnIndependently": false, "allowedOutsideImage": false, "highlight": true, "active": false }, "end": { "x": 212.14302551629262, "y": 196.42592706286837, "index": 1, "drawnIndependently": false, "allowedOutsideImage": false, "highlight": true, "active": false, "moving": false }, "perpendicularStart": { "x": 274.50844791314915, "y": 189.13319621807466, "index": 2, "drawnIndependently": false, "allowedOutsideImage": false, "highlight": true, "active": false, "locked": false }, "perpendicularEnd": { "x": 255.3964636302415, "y": 241.9426264734774, "index": 3, "drawnIndependently": false, "allowedOutsideImage": false, "highlight": true, "active": false }, "textBox": { "x": 267.76188602709806, "y": 164.64989562868368, "index": null, "drawnIndependently": true, "allowedOutsideImage": true, "highlight": false, "active": false, "hasMoved": true, "movesIndependently": false, "hasBoundingBox": true, "boundingBox": { "width": 96.234375, "height": 45, "left": 510.692968726158, "top": 141.18515014648438 } } }, "longestDiameter": "50.5", "shortestDiameter": "25.2", "uuid": "5bdda424-3cd3-45c0-aee0-6db6cbbc347b" } ] } };

This is the method that I trying to create new annotation. image This is the connerstoneviewport image image image

This method I have reference from this issues: https://github.com/cornerstonejs/cornerstoneTools/issues/30#issuecomment-101554604

Expected behavior: (What you expected to happen)

I want to load the annotation data that was saved as json and when phasejson back to object like ExampleData it suppose to create a new annotation from the save json. image

Actual behavior: image