@@ -25,12 +25,29 @@ export default class DICOMSRDisplayTool extends AnnotationTool {
2525 _getTextBoxLinesFromLabels ( labels ) {
2626 // TODO -> max 5 for now (label + shortAxis + longAxis), need a generic solution for this!
2727
28+ if ( ! labels ?. length ) {
29+ return [ ] ;
30+ }
31+
2832 const labelLength = Math . min ( labels . length , 5 ) ;
2933 const lines = [ ] ;
3034
3135 for ( let i = 0 ; i < labelLength ; i ++ ) {
3236 const labelEntry = labels [ i ] ;
33- lines . push ( `${ _labelToShorthand ( labelEntry . label ) } : ${ labelEntry . value } ` ) ;
37+ const shorthand = _labelToShorthand ( labelEntry . label ) ;
38+ const value = labelEntry . value ?? '' ;
39+
40+ /**
41+ * Empty shorthand (CORNERSTONEFREETEXT, Length, etc.): show value only — avoids ": text" or
42+ * "363698007: site" when label was a raw code (fixed at source for finding site).
43+ */
44+ if ( shorthand === '' && value !== '' ) {
45+ lines . push ( String ( value ) ) ;
46+ } else if ( shorthand === '' ) {
47+ continue ;
48+ } else {
49+ lines . push ( `${ shorthand } : ${ value } ` ) ;
50+ }
3451 }
3552
3653 return lines ;
@@ -225,55 +242,41 @@ export default class DICOMSRDisplayTool extends AnnotationTool {
225242 options
226243 ) {
227244 const canvasCoordinates = [ ] ;
245+ const crossSize = 6 ;
246+
228247 renderableData . map ( ( data , index ) => {
229248 const point = data [ 0 ] ;
230- // This gives us one point for arrow
249+ const [ canvasX , canvasY ] = viewport . worldToCanvas ( point ) ;
231250 canvasCoordinates . push ( viewport . worldToCanvas ( point ) ) ;
232251
233252 if ( data [ 1 ] !== undefined ) {
234253 canvasCoordinates . push ( viewport . worldToCanvas ( data [ 1 ] ) ) ;
254+ drawing . drawArrow (
255+ svgDrawingHelper ,
256+ annotationUID ,
257+ `arrow-${ index } ` ,
258+ canvasCoordinates [ canvasCoordinates . length - 1 ] ,
259+ canvasCoordinates [ canvasCoordinates . length - 2 ] ,
260+ { color : options . color , width : options . lineWidth }
261+ ) ;
262+ } else {
263+ const cx = Number ( canvasX ) ;
264+ const cy = Number ( canvasY ) ;
265+ const crossPaths = [
266+ [ [ cx , cy - crossSize ] , [ cx , cy + crossSize ] ] ,
267+ [ [ cx - crossSize , cy ] , [ cx + crossSize , cy ] ] ,
268+ ] ;
269+ drawing . drawPath (
270+ svgDrawingHelper ,
271+ annotationUID ,
272+ `cross-${ index } ` ,
273+ crossPaths ,
274+ { color : options . color , lineWidth : options . lineWidth || 2 }
275+ ) ;
235276 }
236- else {
237- // We get the other point for the arrow by using the image size
238- const imagePixelModule = metaData . get ( 'imagePixelModule' , referencedImageId ) ;
239-
240- let xOffset = 10 ;
241- let yOffset = 10 ;
242-
243- if ( imagePixelModule ) {
244- const { columns, rows } = imagePixelModule ;
245- xOffset = columns / 10 ;
246- yOffset = rows / 10 ;
247- }
248-
249- const imagePoint = csUtils . worldToImageCoords ( referencedImageId , point ) ;
250- const arrowEnd = csUtils . imageToWorldCoords ( referencedImageId , [
251- imagePoint [ 0 ] + xOffset ,
252- imagePoint [ 1 ] + yOffset ,
253- ] ) ;
254-
255- canvasCoordinates . push ( viewport . worldToCanvas ( arrowEnd ) ) ;
256-
257- }
258-
259-
260- const arrowUID = `${ index } ` ;
261-
262- // Todo: handle drawing probe as probe, currently we are drawing it as an arrow
263- drawing . drawArrow (
264- svgDrawingHelper ,
265- annotationUID ,
266- arrowUID ,
267- canvasCoordinates [ 1 ] ,
268- canvasCoordinates [ 0 ] ,
269- {
270- color : options . color ,
271- width : options . lineWidth ,
272- }
273- ) ;
274277 } ) ;
275278
276- return canvasCoordinates ; // used for drawing textBox
279+ return canvasCoordinates ;
277280 }
278281
279282 renderEllipse (
@@ -343,15 +346,19 @@ export default class DICOMSRDisplayTool extends AnnotationTool {
343346 }
344347
345348 const { annotationUID, data = { } } = annotation ;
346- const { labels } = data ;
349+ const { labels, label } = data ;
347350 const { color } = options ;
348351
349352 let adaptedCanvasCoordinates = canvasCoordinates ;
350- // adapt coordinates if there is an adapter
353+
351354 if ( typeof canvasCoordinatesAdapter === 'function' ) {
352355 adaptedCanvasCoordinates = canvasCoordinatesAdapter ( canvasCoordinates ) ;
353356 }
354- const textLines = this . _getTextBoxLinesFromLabels ( labels ) ;
357+
358+ const textLines =
359+ typeof label === 'string' && label . length > 0
360+ ? [ label ]
361+ : this . _getTextBoxLinesFromLabels ( labels ) ;
355362 const canvasTextBoxCoords = utilities . drawing . getTextBoxCoordsCanvas ( adaptedCanvasCoordinates ) ;
356363
357364 if ( ! annotation . data ?. handles ?. textBox ?. worldPosition ) {
@@ -374,6 +381,7 @@ export default class DICOMSRDisplayTool extends AnnotationTool {
374381 {
375382 ...textBoxOptions ,
376383 color,
384+ padding : textBoxOptions . padding ?? 6 ,
377385 }
378386 ) ;
379387
0 commit comments