Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Tool - Height Tool #1508

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,18 @@
"review",
"userTesting"
]
},
{
"login": "ArturRod",
"name": "Arturo Rodrigo",
"avatar_url": "https://avatars.githubusercontent.com/u/86238895?v=4",
"profile": "https://github.com/ArturRod",
"contributions": [
"code",
"content",
"example",
"tool"
]
}
],
"contributorsPerLine": 7
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- prettier-ignore-start -->
[![Build Status][build-badge]][build]
[![Coverage Status][coverage-badge]][coverage]
[![All Contributors](https://img.shields.io/badge/all_contributors-37-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-38-orange.svg?style=flat-square)](#contributors)

[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
Expand Down Expand Up @@ -168,7 +168,7 @@ Thanks goes to these people ([emoji key][emojis]):
| [<img src="https://avatars3.githubusercontent.com/u/3358381?v=4" width="100px;" alt="Juan Narvaez"/><br /><sub><b>Juan Narvaez</b></sub>](https://github.com/jdnarvaez)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=jdnarvaez "Code") | [<img src="https://avatars0.githubusercontent.com/u/814227?v=4" width="100px;" alt="Mike"/><br /><sub><b>Mike</b></sub>](https://github.com/mikehazell)<br />[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mikehazell "Documentation") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mikehazell "Code") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mikehazell "Tests") | [<img src="https://avatars2.githubusercontent.com/u/3329885?v=4" width="100px;" alt="Sangkeun Kim"/><br /><sub><b>Sangkeun Kim</b></sub>](http://sisobus.com)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=sisobus "Code") [💬](#question-sisobus "Answering Questions") | [<img src="https://avatars3.githubusercontent.com/u/378021?v=4" width="100px;" alt="Victor Saase"/><br /><sub><b>Victor Saase</b></sub>](https://github.com/vsaase)<br />[🤔](#ideas-vsaase "Ideas, Planning, & Feedback") | [<img src="https://avatars2.githubusercontent.com/u/120943?v=4" width="100px;" alt="Michael Wasser"/><br /><sub><b>Michael Wasser</b></sub>](http://www.mikewasser.com)<br />[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=untoldone "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/11068601?v=4" width="100px;" alt="Amandeep Singh"/><br /><sub><b>Amandeep Singh</b></sub>](https://github.com/singhArmani)<br />[🖋](#content-singhArmani "Content") | [<img src="https://avatars0.githubusercontent.com/u/1474137?v=4" width="100px;" alt="Madison Dickson"/><br /><sub><b>Madison Dickson</b></sub>](http://mix3dstudios.com)<br />[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mix3d "Documentation") |
| [<img src="https://avatars1.githubusercontent.com/u/3342530?v=4" width="100px;" alt="Kevin Lee Drum"/><br /><sub><b>Kevin Lee Drum</b></sub>](https://github.com/kevinleedrum)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=kevinleedrum "Code") | [<img src="https://avatars3.githubusercontent.com/u/11224291?v=4" width="100px;" alt="Makarand Bauskar"/><br /><sub><b>Makarand Bauskar</b></sub>](https://github.com/mmbauskar)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mbauskar "Code") | [<img src="https://avatars0.githubusercontent.com/u/1713255?v=4" width="100px;" alt="Biharck Araujo"/><br /><sub><b>Biharck Araujo</b></sub>](http://www.biharck.com.br)<br />[💡](#example-biharck "Examples") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=biharck "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/5349517?v=4" width="100px;" alt="Devon Bernard"/><br /><sub><b>Devon Bernard</b></sub>](https://www.linkedin.com/in/devonbernard)<br />[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=DevonBernard "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/38315992?v=4" width="100px;" alt="Karl-Heinrich"/><br /><sub><b>Karl-Heinrich</b></sub>](https://github.com/Karl-Heinrich)<br />[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3AKarl-Heinrich "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=Karl-Heinrich "Code") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=Karl-Heinrich "Tests") | [<img src="https://avatars0.githubusercontent.com/u/15172026?v=4" width="100px;" alt="counterxing"/><br /><sub><b>counterxing</b></sub>](https://blog.xingbofeng.com/)<br />[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Axingbofeng "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=xingbofeng "Code") | [<img src="https://avatars0.githubusercontent.com/u/50026015?v=4" width="100px;" alt="Jorge Lopes"/><br /><sub><b>Jorge Lopes</b></sub>](https://github.com/jlopes90)<br />[💬](#question-jlopes90 "Answering Questions") |
| [<img src="https://avatars2.githubusercontent.com/u/5546851?v=4" width="100px;" alt="Gabriel Garrido"/><br /><sub><b>Gabriel Garrido</b></sub>](http://garrido.io)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=Ggpsv "Code") | [<img src="https://avatars0.githubusercontent.com/u/4126256?v=4" width="100px;" alt="ASVBPREAUBV"/><br /><sub><b>ASVBPREAUBV</b></sub>](https://github.com/ASVBPREAUBV)<br />[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=ASVBPREAUBV "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/50960211?v=4" width="100px;" alt="frolic06"/><br /><sub><b>frolic06</b></sub>](https://github.com/frolic06)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=frolic06 "Code") | [<img src="https://avatars2.githubusercontent.com/u/26968918?v=4" width="100px;" alt="codepage949"/><br /><sub><b>codepage949</b></sub>](https://github.com/codepage949)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=codepage949 "Code") | [<img src="https://avatars.githubusercontent.com/u/1915?v=4" width="100px;" alt="Asherah Connor"/><br /><sub><b>Asherah Connor</b></sub>](https://kivikakk.ee)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=kivikakk "Code") | [<img src="https://avatars.githubusercontent.com/u/22633385?v=4" width="100px;" alt="Ikko Ashimine"/><br /><sub><b>Ikko Ashimine</b></sub>](https://bandism.net/)<br />[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Aeltociear "Bug reports") | [<img src="https://avatars.githubusercontent.com/u/27778909?v=4" width="100px;" alt="Bill Wallace"/><br /><sub><b>Bill Wallace</b></sub>](https://github.com/wayfarer3130)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=wayfarer3130 "Code") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=wayfarer3130 "Documentation") |
| [<img src="https://avatars.githubusercontent.com/u/3341923?v=4" width="100px;" alt="Bruno Alves de Faria"/><br /><sub><b>Bruno Alves de Faria</b></sub>](http://radicalimaging.com/)<br />[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Abrunoalvesdefaria "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Code") [🖋](#content-brunoalvesdefaria "Content") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Documentation") [🔌](#plugin-brunoalvesdefaria "Plugin/utility libraries") [👀](#review-brunoalvesdefaria "Reviewed Pull Requests") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Tests") [🔧](#tool-brunoalvesdefaria "Tools") [📓](#userTesting-brunoalvesdefaria "User Testing") | [<img src="https://avatars.githubusercontent.com/u/13886933?v=4" width="100px;" alt="Igor Octaviano"/><br /><sub><b>Igor Octaviano</b></sub>](http://igoroctaviano.com)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Code") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Documentation") [🚧](#maintenance-igoroctaviano "Maintenance") [👀](#review-igoroctaviano "Reviewed Pull Requests") [📓](#userTesting-igoroctaviano "User Testing") |
| [<img src="https://avatars.githubusercontent.com/u/3341923?v=4" width="100px;" alt="Bruno Alves de Faria"/><br /><sub><b>Bruno Alves de Faria</b></sub>](http://radicalimaging.com/)<br />[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Abrunoalvesdefaria "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Code") [🖋](#content-brunoalvesdefaria "Content") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Documentation") [🔌](#plugin-brunoalvesdefaria "Plugin/utility libraries") [👀](#review-brunoalvesdefaria "Reviewed Pull Requests") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Tests") [🔧](#tool-brunoalvesdefaria "Tools") [📓](#userTesting-brunoalvesdefaria "User Testing") | [<img src="https://avatars.githubusercontent.com/u/13886933?v=4" width="100px;" alt="Igor Octaviano"/><br /><sub><b>Igor Octaviano</b></sub>](http://igoroctaviano.com)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Code") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Documentation") [🚧](#maintenance-igoroctaviano "Maintenance") [👀](#review-igoroctaviano "Reviewed Pull Requests") [📓](#userTesting-igoroctaviano "User Testing") | [<img src="https://avatars.githubusercontent.com/u/86238895?v=4" width="100px;" alt="Arturo Rodrigo"/><br /><sub><b>Arturo Rodrigo</b></sub>](https://github.com/ArturRod)<br />[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=ArturRod "Code") [🖋](#content-ArturRod "Content") [💡](#example-ArturRod "Examples") [🔧](#tool-ArturRod "Tools") |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification.
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<li><a href="#" data-tool="Length">Length</a></li>
<li><a href="#" data-tool="Probe">Probe</a></li>
<li><a href="#" data-tool="RectangleRoi">RectangleRoi</a></li>
<li><a href="#" data-tool="Height">Height</a></li>
</ul>

<ul class="tool-category" data-tool-category="segmentation">
Expand Down
48 changes: 48 additions & 0 deletions src/drawing/drawHeight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import external from './../externalModules.js';
import path from './path.js';

/**
* Draw a line between `start` and `end`.
*
* @public
* @method drawHeight
* @memberof Drawing
*
* @param {CanvasRenderingContext2D} context
* @param {HTMLElement} element - The DOM Element to draw on
* @param {Object} start - `{ x, y } in either pixel or canvas coordinates.
* @param {Object} end - `{ x, y }` in either pixel or canvas coordinates.
* @param {Object} options - See {@link path}
* @param {String} [coordSystem='pixel'] - Can be "pixel" (default) or "canvas". The coordinate
* @param {Number} initialRotation - Ellipse initial rotation
* system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
* is used to transform the points from pixel to canvas coordinates.
* @returns {undefined}
*/
export default function(
context,
element,
start,
end,
options,
coordSystem = 'pixel'
) {

Check warning on line 29 in src/drawing/drawHeight.js

View check run for this annotation

Codecov / codecov/patch

src/drawing/drawHeight.js#L28-L29

Added lines #L28 - L29 were not covered by tests
if (coordSystem === 'pixel') {
const cornerstone = external.cornerstone;

Check warning on line 31 in src/drawing/drawHeight.js

View check run for this annotation

Codecov / codecov/patch

src/drawing/drawHeight.js#L31

Added line #L31 was not covered by tests

start = cornerstone.pixelToCanvas(element, start);
end = cornerstone.pixelToCanvas(element, end);

Check warning on line 34 in src/drawing/drawHeight.js

View check run for this annotation

Codecov / codecov/patch

src/drawing/drawHeight.js#L33-L34

Added lines #L33 - L34 were not covered by tests
}

// Calc midle in start and end:
const midX = end.x + (start.x - end.x) / 2;

Check warning on line 38 in src/drawing/drawHeight.js

View check run for this annotation

Codecov / codecov/patch

src/drawing/drawHeight.js#L38

Added line #L38 was not covered by tests
// Let midY = end.y + (end.y - start.y) / 2;

// Render:
path(context, options, context => {
context.moveTo(start.x, start.y);
context.lineTo(midX, start.y);
context.lineTo(midX, end.y);
context.lineTo(end.x, end.y);

Check warning on line 46 in src/drawing/drawHeight.js

View check run for this annotation

Codecov / codecov/patch

src/drawing/drawHeight.js#L42-L46

Added lines #L42 - L46 were not covered by tests
});
}
2 changes: 2 additions & 0 deletions src/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import path from './path.js';
import setShadow from './setShadow.js';
import transformCanvasContext from './transformCanvasContext.js';
import resetCanvasContextTransform from './resetCanvasContextTransform.js';
import drawHeight from './drawHeight.js';

// Named exports
export {
Expand All @@ -56,4 +57,5 @@ export {
setShadow,
transformCanvasContext,
resetCanvasContextTransform,
drawHeight,
};
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import {
ProbeTool,
RectangleRoiTool,
TextMarkerTool,
HeightTool,
} from './tools/annotation/index.js';
import {
BrushTool,
Expand Down Expand Up @@ -223,6 +224,7 @@ const cornerstoneTools = {
ProbeTool,
RectangleRoiTool,
TextMarkerTool,
HeightTool,
// ~ Segmentation Tools
BrushTool,
SphericalBrushTool,
Expand Down Expand Up @@ -331,6 +333,7 @@ export {
ProbeTool,
RectangleRoiTool,
TextMarkerTool,
HeightTool,
// ~ Segmentation Tools
BrushTool,
SphericalBrushTool,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
fillOutsideRect,
fillBox,
fillTextLines,
drawHeight,
} from './drawing/index.js';
import { clip, clipToBox, clipBoxToDisplayedArea } from './util/clip.js';
import debounce from './util/debounce';
Expand Down Expand Up @@ -131,6 +132,7 @@ export const lib = {
'drawing/drawLinkedTextBox': drawLinkedTextBox,
'drawing/drawHandles': drawHandles,
'drawing/textBoxWidth': textBoxWidth,
'drawing/drawHeight': drawHeight,

'util/getActiveTool': getActiveTool,
'util/getLuminance': getLuminance,
Expand Down
Loading