mirror of
https://github.com/leaders-of-digital-9-task/dicom-viewer.git
synced 2024-11-21 18:06:33 +03:00
add return and serialize draws
This commit is contained in:
parent
0ea24abb37
commit
4da2145867
41
index.js
41
index.js
|
@ -35,7 +35,6 @@ function createCircle(circleData) {
|
|||
var point2 = new dwv.math.Point2D(circleData.center.x, circleData.center.y+circleData.radius)
|
||||
app.setTool('Draw');
|
||||
var styles = app.getToolboxController().getSelectedTool().style
|
||||
app.undo()
|
||||
var draw = circleFactory.create(
|
||||
[point1, point2],
|
||||
styles,
|
||||
|
@ -75,16 +74,23 @@ function createDraws(drawsData) {
|
|||
|
||||
|
||||
function postCircles() {
|
||||
console.log(app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().children[0].children)
|
||||
circlesAttrs = app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().getChildren()[0].children.filter(e => e.attrs.name == 'circle-group').map(
|
||||
console.log(app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().children)
|
||||
circlesAttrs = app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().getChildren().filter(e => e.attrs.name == 'circle-group').map(
|
||||
(e) => {
|
||||
console.log(e.children)
|
||||
return e.children.filter((e) => e.attrs.name == 'shape').map(e => e.attrs)
|
||||
console.log(e, "eeeeee")
|
||||
return e.children.filter(
|
||||
(ee) => {
|
||||
console.log(e)
|
||||
return ee.attrs.name == 'shape'
|
||||
}
|
||||
).map(e => e.attrs)
|
||||
}
|
||||
)
|
||||
console.log(circlesAttrs)
|
||||
circlesAttrs = circlesAttrs.concat(app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().children[0].children.filter(e => e.attrs.name == 'circle-group').map((e) => {
|
||||
return e.children.filter((e) => e.attrs.name == 'shape').map(e => e.attrs)
|
||||
}))
|
||||
//circleAttrs.concat(app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().children[0])
|
||||
return circlesAttrs.flat().map((e) => {
|
||||
console.log(e)
|
||||
return {
|
||||
type: 'Circle',
|
||||
center: {
|
||||
|
@ -97,6 +103,7 @@ function postCircles() {
|
|||
}
|
||||
|
||||
function postRois() {
|
||||
console.log(app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().children)
|
||||
return app.getActiveLayerGroup().getActiveDrawLayer().getKonvaLayer().children.filter(
|
||||
e => e.attrs.name == 'roi-group'
|
||||
).map(e => {
|
||||
|
@ -143,7 +150,7 @@ function receiveMessage(event)
|
|||
createDraws(data)
|
||||
}
|
||||
else if (data.type == 'getDraws') {
|
||||
window.postMessage({'type': 'returnDraws', data: postDraws()})
|
||||
parent.postMessage({'type': 'returnDraws', data: postDraws()}, "*")
|
||||
}
|
||||
}
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
|
@ -165,10 +172,20 @@ app.loadURLs(['https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/
|
|||
|
||||
app.addEventListener('load', () => {
|
||||
app.setTool('Draw')
|
||||
app.setDrawShape('Circle')
|
||||
setTimeout(() => {app.setDrawShape('Roi'); console.log('circle')}, 3000)
|
||||
setTimeout(() => {console.log(postDraws())}, 6000)
|
||||
|
||||
createCircle({
|
||||
type: 'Circle',
|
||||
center: {
|
||||
x: 10, y: 100
|
||||
},
|
||||
radius: 100
|
||||
})
|
||||
app.setDrawShape('Roi')
|
||||
setTimeout(() => {
|
||||
app.setDrawShape('Circle')
|
||||
}, 3000)
|
||||
setTimeout(() => {
|
||||
console.log(postRois())
|
||||
}, 2000)
|
||||
})
|
||||
|
||||
app.addEventListener('slicechange', function () {
|
||||
|
|
Loading…
Reference in New Issue
Block a user