forked from mi-kas/webDICOM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress worker added. Comments added. Refactoring.
- Loading branch information
Showing
12 changed files
with
101 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
html, body { | ||
display: inline; | ||
padding: 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
|
||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
function CanvasPainter(canvasId) { | ||
this.canvas = document.getElementById(canvasId); | ||
this.context = this.canvas.getContext("2d"); | ||
|
@@ -74,7 +77,7 @@ CanvasPainter.prototype.drawImg = function() { | |
var imgData = tempContext.createImageData(this.currentFile.Columns, this.currentFile.Rows); | ||
var pixelData = this.currentFile.PixelData; | ||
if(typeof pixelData === 'undefined' || pixelData.length === 0) { | ||
// console.log('PixelData undefined'); | ||
//console.log('PixelData undefined'); | ||
$('#errorMsg').append("<p class='ui-state-error ui-corner-all'><span class='ui-icon ui-icon-alert'></span>Can't display image: "+ this.currentFile.PatientsName +" "+ this.currentFile.SeriesDescription +"</p>"); | ||
return; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
function DcmViewer() { | ||
this.toolbox = new Toolbox(this.painter); | ||
this.toolbox; | ||
this.tree; | ||
this.fileParser; | ||
this.scrollIndex = 0; | ||
this.eventsEnabled = false; | ||
this.numFiles = 0; | ||
this.eventsEnabled = false; | ||
this.painters = []; | ||
this.parsedFileList = []; | ||
this.tree; | ||
this.fileParser; | ||
} | ||
|
||
DcmViewer.prototype.init = function() { | ||
this.toolbox = new Toolbox(); | ||
this.matrixHandler($('#matrixView').val()); | ||
this.tree = new Tree(); | ||
this.fileParser = new FileParser(); | ||
|
@@ -48,6 +53,9 @@ DcmViewer.prototype.inputHandler = function(e) { | |
if(e.target.files.length === 0) { | ||
return; | ||
} | ||
|
||
progress(e.target.files.length); | ||
|
||
var fileList = e.target.files; | ||
var dcmList = []; | ||
this.parsedFileList = []; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
function FileParser() { | ||
this.files = []; | ||
} | ||
|
@@ -19,7 +23,7 @@ FileParser.prototype.parseFiles = function(rawFiles, callback) { | |
|
||
if(typeof file === 'undefined') { | ||
goal--; | ||
// console.log("Can't read file: " + rawFile.name); | ||
//console.log("Can't read file: " + rawFile.name); | ||
$('#errorMsg').append("<p class='ui-state-error ui-corner-all'><span class='ui-icon ui-icon-alert'></span>Can't read file: " + rawFile.name + "</p>"); | ||
return; | ||
} | ||
|
@@ -47,7 +51,6 @@ FileParser.prototype.parseFiles = function(rawFiles, callback) { | |
}; | ||
|
||
reader.onloadend = function(e) { | ||
// $("#progressBar").progressbar({ value: ( self.files.length / goal)*100 }); | ||
// Fire callback only when all files are parsed | ||
if(self.files.length === goal) { | ||
self.files.sort(function(a, b) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @desc This JavaScript worker takes the number of files and perform | ||
* progress with a certain delay for the progressbar. | ||
* It posts the current percentual value of the progressbar back to the HTML file. | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
var current = 0; | ||
var max = 100; | ||
var self = this; | ||
|
||
self.addEventListener('message', function(e) { | ||
max = e.data; | ||
self.postMessage('Max: ' + max); | ||
}, false); | ||
|
||
var progress = setInterval(function() { | ||
self.postMessage('Max: ' + max); | ||
if(current >= max) { | ||
clearInterval(progress); | ||
} else { | ||
current += 5; | ||
postMessage(((current / max) * 100).toFixed(0)); | ||
} | ||
}, 20); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
|
||
function Toolbox(painter) { | ||
this.painter = painter; | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
function Toolbox() { | ||
this.tools = { | ||
'Window level': new WindowLevel(), | ||
'Zoom': new Zoom(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
**/ | ||
function Tree() { | ||
var dcmTree = {}; | ||
var _html = []; | ||
|
@@ -9,18 +13,7 @@ function Tree() { | |
$('#errorMsg').empty(); | ||
$('#fileTree').empty().html(dcmRender(buildFromDcmList(list))).tree({ | ||
expanded: 'li:first' | ||
}); | ||
// console.log(fileList.length/68 *1000); | ||
// var $element = $('#progressBar'); | ||
// var progressBarWidth = $element.width(); | ||
// $element.show().find('div').addClass('ui-corner-right').animate({width: 270}, fileList.length/68 *1000); | ||
// $('#progressBar').show(); | ||
// $('#loadingIndicator').show(); | ||
// $('*').css('cursor', 'wait'); | ||
|
||
// $('#progressBar').hide(); | ||
//// $('#loadingIndicator').hide(); | ||
// $('*').css('cursor', 'default'); | ||
}).hide(); | ||
}; | ||
|
||
var buildFromDcmList = function(files) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/* | ||
* All tools must implement following functions | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
* @required All tools must implement following functions: | ||
* click(x, y, painters) | ||
* dblclick(x, y, painters) | ||
* mousedown(x, y, painters) | ||
* mouseup(x, y, painters) | ||
* mousemove(x, y, painters) | ||
* mouseout(x, y, painters) | ||
*/ | ||
**/ | ||
function Move() { | ||
this.started = false; | ||
this.curX = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/* | ||
* All tools must implement following functions | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
* @required All tools must implement following functions: | ||
* click(x, y, painters) | ||
* dblclick(x, y, painters) | ||
* mousedown(x, y, painters) | ||
* mouseup(x, y, painters) | ||
* mousemove(x, y, painters) | ||
* mouseout(x, y, painters) | ||
*/ | ||
**/ | ||
function Roi() { | ||
this.started = false; | ||
this.startX = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
/* | ||
* All tools must implement following functions | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
* @required All tools must implement following functions: | ||
* click(x, y, painters) | ||
* dblclick(x, y, painters) | ||
* mousedown(x, y, painters) | ||
* mouseup(x, y, painters) | ||
* mousemove(x, y, painters) | ||
* mouseout(x, y, painters) | ||
*/ | ||
**/ | ||
function WindowLevel() { | ||
this.started = false; | ||
this.curX = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
/* | ||
* All tools must implement following functions | ||
/** | ||
* @desc | ||
* @author Michael Kaserer [email protected] | ||
* @required All tools must implement following functions: | ||
* click(x, y, painters) | ||
* dblclick(x, y, painters) | ||
* mousedown(x, y, painters) | ||
* mouseup(x, y, painters) | ||
* mousemove(x, y, painters) | ||
* mouseout(x, y, painters) | ||
*/ | ||
**/ | ||
function Zoom() { | ||
this.started = false; | ||
// this.curX = 0; | ||
this.curY = 0; | ||
} | ||
|
||
|
@@ -26,7 +26,7 @@ Zoom.prototype.mouseup = function() { | |
|
||
Zoom.prototype.mousemove = function(x, y, painters) { | ||
if(this.started) { | ||
// var deltaX = x - this.curX; | ||
//var deltaX = x - this.curX; | ||
var deltaY = this.curY - y; | ||
var newDeltaY = painters[0].getScale() + deltaY / 100.0; | ||
|
||
|
@@ -35,7 +35,7 @@ Zoom.prototype.mousemove = function(x, y, painters) { | |
painters[i].drawImg(); | ||
} | ||
} | ||
// this.curX = x; | ||
//this.curX = x; | ||
this.curY = y; | ||
}; | ||
|
||
|