Skip to content

Commit

Permalink
support polyline, point, and ellipse. filter series are ANN and MS fo…
Browse files Browse the repository at this point in the history
…rmat dicom
  • Loading branch information
nanli-emory committed May 15, 2024
1 parent 6b4dc11 commit 1ce68cf
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 27 deletions.
6 changes: 4 additions & 2 deletions apps/dicom-connect/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ function initialize() {

getSeries(src.url, params.studyId).then(function(data) {
// add source and study id
data = data.filter(d=>d['00080060']['Value'][0] == 'ANN' || d['00080060']['Value'][0] == 'SM')
data.forEach(elt=>{
elt.source=src.name
elt.url=src.url
Expand Down Expand Up @@ -256,9 +257,10 @@ function initialize() {
};

let annotationCount = await store.countMarks(annotationQuery);
console.info("Counted " + annotationCount[0].count + " mark objects for " + series);


if (annotationCount[0].count > 0) {
if (annotationCount&&annotationCount[0].count > 0) {
console.info("Counted " + annotationCount[0].count + " mark objects for " + series);
d.status = 'done';
d.slideId = slides[0]._id.$oid;
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/mini/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ function convertGeometries(features, data) {
size: size,
},
geometry: {
type: 'LineString',
type: 'Polyline',
coordinates: [points],
},
bound: {
Expand Down
2 changes: 1 addition & 1 deletion apps/viewer/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ function convertGeometries(features, data) {
size: size,
},
geometry: {
type: 'LineString',
type: 'Polyline',
coordinates: [points],
},
bound: {
Expand Down
12 changes: 8 additions & 4 deletions common/DrawHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ caDrawHelper.prototype.ellipse = function(ctx, point, radius, rotation){
2 * Math.PI
);
path.closePath();
// path.strokeAndFill(ctx);
path.stroke(ctx);
if(ctx.isFill ==undefined || ctx.isFill){
path.fill(ctx);
//path.stroke(ctx);
}else{
path.stroke(ctx);
}
// return points and path
return path;
}
Expand Down Expand Up @@ -205,7 +209,7 @@ caDrawHelper.prototype.draw = function(ctx, image_data){

// if no data
const points = polygon.geometry.coordinates[0];
if(polygon.geometry.type=='LineString'){
if(polygon.geometry.type=='Polyline'){
// determine drawing or not
if(ctx.viewBoundBoxInData
&& polygon.bound
Expand Down Expand Up @@ -242,7 +246,7 @@ caDrawHelper.prototype.draw = function(ctx, image_data){
if(ctx.viewBoundBoxInData
&& !this.isPointInBBox(ctx.viewBoundBoxInData, {x:point[0],y:point[1]})) continue;

ctx.fillStyle = (ctx.isFill ==undefined || ctx.isFill)?hexToRgbA(style.color,1):style.color;
ctx.fillStyle = (ctx.isFill ==undefined || ctx.isFill)?hexToRgbA(style.color,0.5):style.color;
polygon.geometry.path = this.ellipse(ctx, polygon.geometry.coordinates, polygon.geometry.radius, polygon.geometry.rotation);
}
else if(false){
Expand Down
2 changes: 1 addition & 1 deletion components/layersviewer/layersviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ LayersViewer.prototype.__initUI = function() {
checkDiv.classList.add('checklist');
checkDiv.style.display = 'none';
checkDiv.innerHTML = `<label><input type='checkbox' value='Point' checked/> Point</label>
<label><input type='checkbox' value='LineString' checked/> Brush</label>
<label><input type='checkbox' value='Polyline' checked/> Brush</label>
<label><input type='checkbox' value='Polygon' checked/> Polygon</label>`;
this.elt.appendChild(checkDiv);
this.searchList = checkDiv;
Expand Down
4 changes: 2 additions & 2 deletions core/extension/openseadragon-canvas-draw-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,15 +1046,15 @@
geometry: {
type:
this.drawMode === 'line' || this.drawMode === 'grid' ?
'LineString' :
'Polyline' :
'Polygon',
coordinates: [[point]],
path: null,
},
bound: {
type:
this.drawMode === 'line' || this.drawMode === 'grid' ?
'LineString' :
'Polyline' :
'Polygon',
coordinates: [[point]],
},
Expand Down
6 changes: 3 additions & 3 deletions core/extension/openseadragon-overlays-manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
pointPath.strokeAndFill(this._edit_tool_ctx_);
this.editPointPathList.push(pointPath);
})
} else if (this.editPathData.geometry.type === 'LineString') {
} else if (this.editPathData.geometry.type === 'Polyline') {
// brush
this.editPathData.geometry.coordinates[0].splice(i,1);
this.editPathData.geometry.coordinates[0].map((point) => {
Expand All @@ -214,7 +214,7 @@
return;
}
}
if (this.editPathData.geometry.type === 'LineString') {
if (this.editPathData.geometry.type === 'Polyline') {
const size = this.editPathData.properties.size;
const topleft = [Math.floor(img_point.x/size[0])*size[0], Math.floor(img_point.y/size[1])*size[1]];
const index = pointInPolygonVertex(this.editPathData.geometry.coordinates[0], topleft);
Expand Down Expand Up @@ -529,7 +529,7 @@
},

onEditPointMouseUp: function(e) {
if (this.editPathData?.geometry.type === 'LineString') {
if (this.editPathData?.geometry.type === 'Polyline') {
if (!this.onEdit) return;
DrawHelper.clearCanvas(this._edit_tool_);
const point = new OpenSeadragon.Point(e.clientX, e.clientY);
Expand Down
64 changes: 51 additions & 13 deletions core/extension/osd-segment-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@
const ctx = this._display_ctx_;
this._data.forEach(d=>{
d.data.forEach(segment=>{


const polygon = segment.geometries.features[0];
const points = polygon.geometry.coordinates[0];
const style = polygon.properties.style;
Expand All @@ -392,20 +394,56 @@
this._display_ctx_.strokeStyle = style.color;
}
this._display_ctx_.beginPath()
// starting draw drawPolygon
this._display_ctx_.moveTo(
convertX(points[0][0]) + this._offset[0],
convertY(points[0][1]) + this._offset[1],
);

for (var i = 1; i < points.length-1; i++) {
const x = convertX(points[i][0]);
const y = convertY(points[i][1]);
this._display_ctx_.lineTo(x+this._offset[0],y+this._offset[1]);

//
if(polygon.geometry.type == 'Point') {
this._display_ctx_.arc(
convertX(points[0]) + this._offset[0],
convertY(points[1]) + this._offset[1],
this._display_ctx_.radius * 2, 0, 2 * Math.PI
);

} else if (polygon.geometry.type == 'Ellipse') {
this._display_ctx_.ellipse(
convertX(points[0]) + this._offset[0],
convertY(points[1]) + this._offset[1],
convertX(radius[0]),
convertX(radius[1]),
polygon.geometry.rotation,
0,
2 * Math.PI
)
} else if (polygon.geometry.type == 'Polyline') {
// starting draw line
this._display_ctx_.moveTo(
convertX(points[0][0]) + this._offset[0],
convertY(points[0][1]) + this._offset[1],
);
for (var i = 1; i < points.length-1; i++) {
const x = convertX(points[i][0]);
const y = convertY(points[i][1]);
this._display_ctx_.lineTo(x+this._offset[0],y+this._offset[1]);
}

} else {
// starting draw drawPolygon
this._display_ctx_.moveTo(
convertX(points[0][0]) + this._offset[0],
convertY(points[0][1]) + this._offset[1],
);

for (var i = 1; i < points.length-1; i++) {
const x = convertX(points[i][0]);
const y = convertY(points[i][1]);
this._display_ctx_.lineTo(x+this._offset[0],y+this._offset[1]);
}
this._display_ctx_.lineTo(
convertX(points[0][0]) + this._offset[0],
convertY(points[0][1]) + this._offset[1]);
}
this._display_ctx_.lineTo(
convertX(points[0][0]) + this._offset[0],
convertY(points[0][1]) + this._offset[1]);



if(this.mode === 'fill'){
this._display_ctx_.fill();
}else if(this.mode === 'stroke'){
Expand Down

0 comments on commit 1ce68cf

Please sign in to comment.