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