Skip to content

Commit

Permalink
Patient data finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-kas committed Apr 14, 2013
1 parent d941527 commit f625930
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 59 deletions.
15 changes: 10 additions & 5 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ html, body {
}
.viewerCells {
display: table-cell;
position:relative;
}
canvas {
cursor:default;
Expand All @@ -75,28 +76,28 @@ canvas {

/*Patient infos*/

#patientInfo {
.patientInfo {
color: #fff;
font-size: 0.8em;
text-align: right;
position: absolute;
top: 5px;
right: 5px;
}
#patientInfo ul {
.patientInfo ul {
list-style: none;
margin: 0;
padding: 0;
}
#studyInfo {
.studyInfo {
color: #fff;
font-size: 0.8em;
text-align: left;
position: absolute;
top: 5px;
left: 5px;
}
#studyInfo ul {
.studyInfo ul {
list-style: none;
margin: 0;
padding: 0;
Expand All @@ -105,12 +106,16 @@ canvas {
/*Toolbox*/

#toolbox {
margin: 0;
margin-left: -1px;
padding: 10px;
margin-bottom: 0;
}
#toolbox div{
float:left;
}
#toolboxHeader {
background-color: #fff;
}
#matrixViewSelectBoxItText {
padding-left:7px;
}
Expand Down
51 changes: 32 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
if(e.target.nodeName === 'A' && e.target.dataset.type === 'file') {
var serie = [];
var arr = e.target.dataset.index.split(',');
// console.log(arr.length);
// console.log(arr);
for(var i = 0; i < arr.length; i++) {
serie.push(tree.parsedFileList[arr[i]]);
}
Expand All @@ -68,7 +66,7 @@
dcmViewer.setCurrentTool($("input[name='toolbox-buttons']:checked").val());
});
$('#matrixView').change(function(e) {
dcmViewer.matrixHandler(e.target.value);
dcmViewer.matrixHandler(e.target.value);
});
$('#resetButton').click(function() {
dcmViewer.resetHandler();
Expand All @@ -81,6 +79,17 @@
});
}
});
$('#showStudyData').click(function() {
if($('.studyInfo').is(':visible')) {
$('.studyInfo').hide();
$('.patientInfo').hide();
$('#showStudyData').text('Show Infos');
} else {
$('.studyInfo').show();
$('.patientInfo').show();
$('#showStudyData').text('Hide Infos');
}
});

$('#viewerScreen').click(function(e) {
dcmViewer.eventHandler(e);
Expand Down Expand Up @@ -117,6 +126,7 @@
$('#buttonSet').buttonset();
$('#resetButton').button();
$('#metaButton').button();
$('#showStudyData').button();
$('#matrixView').selectBoxIt();
$("#slider").slider({
disabled: true
Expand Down Expand Up @@ -161,24 +171,27 @@
<div id="fileTree"></div>
</aside>
<div id="viewer">
<div id="toolbox" class="ui-toolbar ui-widget-header clearfix">
<div id="buttonSet">
<input type="radio" id="windowLevel" name="toolbox-buttons" value="Window level" checked="checked" /><label for="windowLevel">Window level</label>
<input type="radio" id="move" name="toolbox-buttons" value="Move" /><label for="move">Move</label>
<input type="radio" id="zoom" name="toolbox-buttons" value="Zoom" /><label for="zoom">Zoom</label>
</div>
<div id="toolboxHeader">
<div id="toolbox" class="ui-toolbar ui-widget-header clearfix">
<div id="buttonSet">
<input type="radio" id="windowLevel" name="toolbox-buttons" value="Window level" checked="checked" /><label for="windowLevel">Window level</label>
<input type="radio" id="move" name="toolbox-buttons" value="Move" /><label for="move">Move</label>
<input type="radio" id="zoom" name="toolbox-buttons" value="Zoom" /><label for="zoom">Zoom</label>
</div>

<div id="singleButtons">
<select id="matrixView" name="matrixView">
<option value="1,1" selected>1 x 1</option>
<option value="1,2">1 x 2</option>
<option value="2,2">2 x 2</option>
<option value="4,4">4 x 4</option>
</select>
<button type="button" id="resetButton" value="Reset">Reset</button>
<button type="button" id="metaButton" value="Meta-Daten">Meta-Daten</button>
<div id="singleButtons">
<select id="matrixView" name="matrixView">
<option value="1,1" selected>1 x 1</option>
<option value="1,2">1 x 2</option>
<option value="2,2">2 x 2</option>
<option value="4,4">4 x 4</option>
</select>
<button type="button" id="metaButton" value="Meta-Daten">Meta-Data</button>
<button type="button" id="resetButton" value="Reset">Reset</button>
<button type="button" id="showStudyData">Hide Infos</button>
</div>
<div id="slider"></div>
</div>
<div id="slider"></div>
</div>

<div id="viewerScreen"></div>
Expand Down
89 changes: 56 additions & 33 deletions js/DcmViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ DcmViewer.prototype.setParsedFiles = function(files) {
var index = (this.scrollIndex + i) % this.numFiles;
this.painters[i].currentFile = this.painters[i].series[index];
this.painters[i].drawImg();
// update info
updateInfo(this.painters[i], getSelector(this.painters[i]));
}
this.eventsEnabled = true;
// clearInfo();
// updateInfo(this.painter);
if(this.numFiles > 1) {
var self = this;
$("#slider").slider('option', {
Expand All @@ -37,7 +37,6 @@ DcmViewer.prototype.setParsedFiles = function(files) {
}
});
}
//console.log(this.numFiles);
};

DcmViewer.prototype.eventHandler = function(e) {
Expand All @@ -46,9 +45,8 @@ DcmViewer.prototype.eventHandler = function(e) {
e.x = !e.offsetX ? (e.pageX - $(e.target).offset().left) : e.offsetX;
e.y = !e.offsetY ? (e.pageY - $(e.target).offset().top) : e.offsetY;

//Update X & Y values
$('#xPos').text('X: ' + e.x.toFixed(0));
$('#yPos').text('Y: ' + e.y.toFixed(0));
$('.xPos').text('X: ' + e.x.toFixed(0));
$('.yPos').text('Y: ' + e.y.toFixed(0));

// pass the event to the currentTool of the toolbox
var eventFunc = this.toolbox.currentTool[e.type];
Expand All @@ -75,10 +73,10 @@ DcmViewer.prototype.scrollHandler = function(evt) {
tmp.push(index);
this.painters[i].currentFile = this.painters[i].series[index];
this.painters[i].drawImg();
// Update instance number
var instanceNum = this.painters[i].currentFile.InstanceNumber ? this.painters[i].currentFile.InstanceNumber : ' - ';
$(getSelector(this.painters[i]) + ' #instanceNum').text(instanceNum + ' / ' + this.numFiles);
}
//console.log(tmp);
// var instanceNum = this.painter.currentFile.InstanceNumber ? this.painter.currentFile.InstanceNumber : ' - ';
// $('#instanceNum').text(instanceNum + ' / ' + this.numFiles);

return this.scrollIndex;
}
Expand All @@ -90,10 +88,10 @@ DcmViewer.prototype.scrollOne = function(num) {
var index = (this.scrollIndex + i) % this.numFiles;
this.painters[i].currentFile = this.painters[i].series[index];
this.painters[i].drawImg();
// Update instance number
var instanceNum = this.painters[i].currentFile.InstanceNumber ? this.painters[i].currentFile.InstanceNumber : ' - ';
$(getSelector(this.painters[i]) + ' #instanceNum').text(instanceNum + ' / ' + this.numFiles);
}

// var instanceNum = this.painter.currentFile.InstanceNumber ? this.painter.currentFile.InstanceNumber : ' - ';
// $('#instanceNum').text(instanceNum + ' / ' + this.numFiles);
};

DcmViewer.prototype.matrixHandler = function(e) {
Expand All @@ -116,7 +114,9 @@ DcmViewer.prototype.matrixHandler = function(e) {
var tmpId = '#' + rowName + ' #column' + x;
var newId = 'canvas' + x + '' + y;
$(tmpId).append('<canvas id="' + newId + '" width="' + cellWidth + '" height="' + cellHeight + '">Your browser does not support HTML5 canvas</canvas>');

$(tmpId).append('<div class="studyInfo"></div>');
$(tmpId).append('<div class="patientInfo"></div>');

var tmpPainter = new CanvasPainter(newId);
newPainters.push(tmpPainter);
if(this.eventsEnabled) {
Expand All @@ -125,6 +125,7 @@ DcmViewer.prototype.matrixHandler = function(e) {
tmpPainter.setSeries(this.painters[0].series);
tmpPainter.currentFile = tmpPainter.series[index];
tmpPainter.drawImg();
updateInfo(tmpPainter, getSelector(tmpPainter));
}
}
}
Expand Down Expand Up @@ -194,7 +195,7 @@ DcmViewer.prototype.openMetaDialog = function() {
return table;
};

var updateInfo = function(_this) {
var updateInfo = function(_this, selector) {
var isValidDate = function(d) {
if(Object.prototype.toString.call(d) !== "[object Date]")
return false;
Expand Down Expand Up @@ -234,25 +235,47 @@ var updateInfo = function(_this) {

var sDesc = _this.currentFile.StudyDescription ? _this.currentFile.StudyDescription : ' - ';

$('#patientsName').text(pName + pSex + pID);
$('#age').text(pDate);
$('#wCenter').text('WC: ' + _this.wc.toFixed(0));
$('#wWidth').text('WW: ' + _this.ww.toFixed(0));
$('#xPos').text('X: 0');
$('#yPos').text('Y: 0');
$('#instanceNum').text(instanceNum + ' / ' + _this.series.length);
$('#studyDate').text(sDate);
$('#studyDescription').text(sDesc);
var ul1 = document.createElement('ul');
var li11 = document.createElement('li');
li11.appendChild(document.createTextNode(pName + pSex + pID));
var li12 = document.createElement('li');
li12.appendChild(document.createTextNode(pDate));
var li13 = document.createElement('li');
li13.appendChild(document.createTextNode(sDesc));
var li14 = document.createElement('li');
li14.appendChild(document.createTextNode(sDate));
ul1.appendChild(li11);
ul1.appendChild(li12);
ul1.appendChild(li13);
ul1.appendChild(li14);
var ul2 = document.createElement('ul');
var li21 = document.createElement('li');
li21.appendChild(document.createTextNode('WC: ' + _this.wc.toFixed(0)));
li21.setAttribute("class", "wCenter");
var li22 = document.createElement('li');
li22.appendChild(document.createTextNode('WW: ' + _this.ww.toFixed(0)));
li22.setAttribute("class", "wWidth");
var li23 = document.createElement('li');
li23.appendChild(document.createTextNode('X: 0'));
li23.setAttribute("class", "xPos");
var li24 = document.createElement('li');
li24.appendChild(document.createTextNode('Y: 0'));
li24.setAttribute("class", "yPos");
var li25 = document.createElement('li');
li25.appendChild(document.createTextNode(instanceNum + ' / ' + _this.series.length));
li25.setAttribute("id", "instanceNum");
ul2.appendChild(li21);
ul2.appendChild(li22);
ul2.appendChild(li23);
ul2.appendChild(li24);
ul2.appendChild(li25);

$(selector + ' .studyInfo').empty().append(ul2);
$(selector + ' .patientInfo').empty().append(ul1);
};

var clearInfo = function() {
$('#patientsName').text('');
$('#age').text('');
$('#wCenter').text('');
$('#wWidth').text('');
$('#xPos').text('');
$('#yPos').text('');
$('#instanceNum').text('');
$('#studyDate').text('');
$('#studyDescription').text('');
var getSelector = function(painter) {
var row = painter.canvas.id.charAt(7);
var column = painter.canvas.id.charAt(6);
return '#row' + row + ' #column' + column;
};
5 changes: 3 additions & 2 deletions js/tools/WindowLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ WindowLevel.prototype.mousemove = function(x, y, painters) {
painters[i].setWindowing(newX, newY);
painters[i].drawImg();
}
$('#wCenter').text('WC: ' + newX.toFixed(0));
$('#wWidth').text('WW: ' + newY.toFixed(0));
//Update all infos
$('.wCenter').text('WC: ' + newX.toFixed(0));
$('.wWidth').text('WW: ' + newY.toFixed(0));
}
this.curX = x;
this.curY = y;
Expand Down

0 comments on commit f625930

Please sign in to comment.