cornerstone-tools
Advanced tools
Comparing version 1.1.3 to 2.0.0
@@ -26,3 +26,10 @@ module.exports = { | ||
'camelcase': 'warn', | ||
'capitalized-comments': 'warn', | ||
'capitalized-comments': [ | ||
"warn", | ||
"always", | ||
{ | ||
"ignorePattern": "pragma|ignored", | ||
"ignoreInlineComments": true | ||
} | ||
], | ||
'class-methods-use-this': 'warn', | ||
@@ -29,0 +36,0 @@ 'comma-dangle': 'warn', |
@@ -7,2 +7,40 @@ # Changelog | ||
## [2.0.0] - 2017-12-13 | ||
### Added | ||
- Began the [Getting Started guide](https://tools.cornerstonejs.org/essentials/getting-started.html) (thanks @dannyrb) | ||
- Since we are now using addEventListener/removeEventListener instead of jQuery's on/off, we had to create a separate cache for event data for each element / tool type combination since it cannot be passed to the handler when creating the listener. | ||
This is present in toolOptions.js and available as ````setToolOptions(toolType, element, options)```` and ````getToolOptions(toolType, element)````. These are now used to keep track of which mouse button is enabled for which tool and element. | ||
### Changed | ||
- *Breaking Change!!!* Removed all dependence on jQuery. This was a long process and we'd like to thank all the contributors that have come forward from the community to help. | ||
If you are listening to any Cornerstone Tools event, and your event handler has the signature | ||
````javascript | ||
function(event, eventData) { | ||
// do stuff | ||
}```` | ||
You need to switch it to: | ||
````javascript | ||
function(event) { | ||
const eventData = event.detail; | ||
// do stuff | ||
} | ||
```` | ||
since this is how it is now being fired using native CustomEvents. | ||
- *Breaking Change!!!* Lower-cased all event names. This was done because we had two parallel sets of events (jQuery events and native Custom Events) in the previous major version. The jQuery events have now been removed. Check events.js for the list of event names. e.g. CornerstoneToolsMouseDrag -> cornerstonetoolsmousedrag | ||
- *Breaking Change!!!* jQuery Events are no longer being dispatched by triggerEvent.js | ||
- *Breaking Change!!!* Cornerstone Tools now depends on Cornerstone Core >= 2.0.0. | ||
- Removed jQuery from nearly all of the examples and replaced with native APIs. It is still being used in the All Image Tools example, solely for the Bootstrap dropdown. | ||
- Centralized all of the event names in events.js | ||
- Switched ESLint's capitalized-comments warning to ignore inline comments | ||
## [1.1.3] - 2017-12-13 | ||
@@ -39,3 +77,3 @@ ### Added | ||
- Internal triggerEvent function which triggers jQuery and CustomEvents side-by-side. These events are the same as the current | ||
event names, but with all lower case letters. E.g. CornerstoneToolsMouseMove => cornerstonetoolsmousemove | ||
event names, but with all lower case letters. E.g. CornerstoneToolsMouseMove => cornerstonetoolsmousemove | ||
@@ -52,7 +90,7 @@ This will be the prevailing format moving forward, but you aren't forced to migrate until 2.0.0 when we plan to drop the jQuery events. | ||
- Biggest change: Tools that required 'imagePlane' metadata, now require 'imagePlaneModule': | ||
- Biggest change: Tools that required 'imagePlane' metadata, now require 'imagePlaneModule': | ||
This is partly a breaking change but in reality will help most users, since CornerstoneWADOImageLoader is populating 'imagePlaneModule', not 'imagePlane'. Thanks to @dannyrb for this fix. | ||
*Note*: If you have written your own metadata provider, you should now use 'imagePlaneModule' instead of 'imagePlane'. | ||
*Note*: If you have written your own metadata provider, you should now use 'imagePlaneModule' instead of 'imagePlane'. | ||
@@ -136,2 +174,2 @@ - Refactored the Brush tool into brush.js and brushTool.js. This works similarly to mouseButtonTool. | ||
- Remove the useless variable 'viewport' in playClip.js and scrollToIndex.js | ||
- LengthTool now uses PixelSpacing provided by MetaDataProvider | ||
- LengthTool now uses PixelSpacing provided by MetaDataProvider |
@@ -23,3 +23,2 @@ const path = require('path'); | ||
files: [ | ||
'node_modules/jquery/dist/jquery.js', | ||
'node_modules/cornerstone-core/dist/cornerstone.js', | ||
@@ -26,0 +25,0 @@ 'node_modules/cornerstone-math/dist/cornerstoneMath.js', |
# Getting Started | ||
> TODO: Barebones code example of getting started. Use packaged source | ||
> We will be using [ES2015](https://github.com/lukehoban/es6features) in the code samples in the guide. | ||
Cornerstone.js provides a rock solid foundation for creating a web medical image viewer. However, it is purposefully light weight and extensible. After configuring an image loader (getting your images to display), the next thing you'll want to do is manipulate those images, apply annotations, and provide additional tools for diagnosis and research. CornerstoneTools sets out to provide tools for these common use cases. Here's a basic example: | ||
### HTML | ||
``` html | ||
<script src="https://unpkg.com/"></script> | ||
<script src="https://unpkg.com/"></script> | ||
<!-- Scripts --> | ||
<!-- Cornerstone Tools External Dependencies --> | ||
<script src="https://unpkg.com/jquery@3.2.1/dist/jquery.js"></script> | ||
<script src="https://unpkg.com/hammerjs@2.0.8/hammer.js"></script> | ||
<script src="https://unpkg.com/cornerstone-math"></script> | ||
<!-- Cornerstone Latest --> | ||
<script src="https://unpkg.com/cornerstone-core"></script> | ||
<script src="https://unpkg.com/cornerstone-web-image-loader"></script> | ||
<!-- Cornerstone Tools Latest --> | ||
<script src="https://unpkg.com/cornerstone-tools"></script> | ||
<script> | ||
// TODO: This should happen automatically. | ||
cornerstoneWebImageLoader.external.cornerstone = cornerstone | ||
</script> | ||
<!-- WRAPPER --> | ||
<div | ||
class="image-canvas-wrapper" | ||
oncontextmenu="return false" | ||
unselectable='on' | ||
onselectstart='return false;' | ||
onmousedown='return false;' | ||
> | ||
<!-- DICOM CANVAS TARGET --> | ||
<div | ||
class="image-canvas" | ||
oncontextmenu="return false" | ||
></div> | ||
</div> | ||
``` | ||
### JS | ||
### JavaScript | ||
Loading libraries as modules is similar, but with one small caveat. We try not to pollute the global namespace, so each library's external dependencies needs to be explicitly linked. You can find documentation on how to do this [in the installation section](/installation.md) | ||
``` js | ||
// 0. Tiny blurb about importing modules and registering externals | ||
// 1. MVP setup for enabling common tools and enabling different types of input | ||
// If we were using the cornerstoneWADOImageLoader, we could load .dcm files | ||
// The cornerstoneWebImageLoader supports loading and displaying .jpg and .png files | ||
const exampleImageId = 'path/to/example-image.jpg' | ||
const element = document.querySelector('.image-canvas') | ||
// Now the app has started! | ||
// Injects cornerstone "enabled" canvas into DOM | ||
cornerstone.enable(element) | ||
// Load & Display | ||
cornerstone | ||
.loadImage(exampleImageId) | ||
.then(function (image) { | ||
// Now that we've "loaded" the image, we can display it on | ||
// our Cornerstone enabled element of choice | ||
cornerstone.displayImage(element, image) | ||
// We need to enable each way we'd like to be able to receive | ||
// and respond to input (mouse, touch, scrollwheel, etc.) | ||
cornerstoneTools.mouseInput.enable(element) | ||
cornerstoneTools.touchInput.enable(element) | ||
// Activate mouse tools we'd like to use | ||
cornerstoneTools.wwwc.activate(element, 1) // left click | ||
cornerstoneTools.pan.activate(element, 2) // middle click | ||
cornerstoneTools.zoom.activate(element, 4) // right click | ||
// Activate Touch / Gesture tools we'd like to use | ||
cornerstoneTools.wwwcTouchDrag.activate(element) // - Drag | ||
cornerstoneTools.zoomTouchPinch.activate(element) // - Pinch | ||
cornerstoneTools.panMultiTouch.activate(element) // - Multi (x2) | ||
}) | ||
``` | ||
### CSS | ||
> Link to a live example | ||
> Note: The canvas viewer is NOT responsive out of the box. To find how to implement a responsive viewer, check out this example: COMING SOON | ||
```css | ||
.image-canvas-wrapper { | ||
width: 500px; | ||
height: 325px; | ||
margin: 35px auto; | ||
background: black; | ||
} | ||
.image-canvas { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
body { | ||
background: dodgerblue; | ||
} | ||
``` | ||
You can also check out this example [live](https://codepen.io/dannyrb/pen/YYzxma). |
@@ -23,2 +23,4 @@ # Cornerstone Tools | ||
- API Reference | ||
- Guides | ||
- [Migrating Major Versions](guides/migrating-major-versions.md) | ||
- [Contributing](contributing.md) |
@@ -57,5 +57,8 @@ (function (cs) { | ||
var deferred = $.Deferred(); | ||
deferred.resolve(image); | ||
return deferred; | ||
return { | ||
promise: new Promise((resolve) => { | ||
resolve(image); | ||
}), | ||
cancelFn: undefined | ||
}; | ||
} | ||
@@ -62,0 +65,0 @@ |
{ | ||
"name": "cornerstone-tools", | ||
"version": "1.1.3", | ||
"version": "2.0.0", | ||
"description": "Medical imaging tools for the Cornerstone library", | ||
@@ -51,6 +51,6 @@ "main": "./dist/cornerstoneTools.min.js", | ||
"chai": "^4.1.2", | ||
"cornerstone-core": "^1.1.3", | ||
"cornerstone-core": "^2.0.0", | ||
"coveralls": "^3.0.0", | ||
"docdash": "^0.4.0", | ||
"eslint": "^4.9.0", | ||
"eslint": "^4.13.1", | ||
"eslint-loader": "^1.9.0", | ||
@@ -63,3 +63,2 @@ "eslint-plugin-import": "^2.8.0", | ||
"istanbul-instrumenter-loader": "^3.0.0", | ||
"jquery": "^3.2.1", | ||
"jsdoc": "^3.5.5", | ||
@@ -69,12 +68,12 @@ "karma": "^1.7.1", | ||
"karma-coverage": "^1.1.1", | ||
"karma-firefox-launcher": "^1.0.1", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-phantomjs-launcher": "^1.0.4", | ||
"karma-webpack": "^2.0.5", | ||
"karma-webpack": "^2.0.6", | ||
"lodash": "^4.17.4", | ||
"mocha": "^4.0.1", | ||
"opn-cli": "^3.1.0", | ||
"phantomjs-prebuilt": "^2.1.15", | ||
"phantomjs-prebuilt": "^2.1.16", | ||
"shx": "^0.2.2", | ||
"webpack": "^3.8.1" | ||
"webpack": "^3.10.0" | ||
}, | ||
@@ -81,0 +80,0 @@ "dependencies": { |
@@ -197,3 +197,2 @@ [![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url] | ||
// Load NPM packages | ||
import $ from 'jquery'; // npm install --save jquery | ||
import Hammer from 'hammerjs'; // npm install --save hammerjs | ||
@@ -204,5 +203,3 @@ import * as cornerstone from 'cornerstone-core'; // npm install --save cornerstone-core | ||
// Specify external dependencies | ||
cornerstone.external.$ = $; | ||
cornerstoneTools.external.cornerstone = cornerstone; | ||
cornerstoneTools.external.$ = $; | ||
cornerstoneTools.external.Hammer = Hammer; | ||
@@ -218,10 +215,8 @@ ```` | ||
// Load Packaged Sources | ||
<script src="https://unpkg.com/jquery@3.2.1/dist/jquery.js"></script> | ||
<script src="https://unpkg.com/hammerjs@2.0.8/hammer.js"></script> | ||
<script src="https://unpkg.com/cornerstone-core@1.1.0/dist/cornerstone.min.js"></script> | ||
<script src="https://unpkg.com/cornerstone-tools@1.0.2/dist/cornerstoneTools.min.js"></script> | ||
<script src="https://unpkg.com/cornerstone-core@2.0.0/dist/cornerstone.min.js"></script> | ||
<script src="https://unpkg.com/cornerstone-tools@2.0.0/dist/cornerstoneTools.min.js"></script> | ||
// Specify external dependencies | ||
cornerstoneTools.external.cornerstone = cornerstone; | ||
cornerstoneTools.external.$ = $; | ||
cornerstoneTools.external.Hammer = Hammer; | ||
@@ -228,0 +223,0 @@ ```` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29
14542500
176
31857
310