From 31bd3a4a8aea9fadd4f98835cca098af65c5b465 Mon Sep 17 00:00:00 2001 From: Richard Date: Sat, 4 Mar 2017 12:09:23 +0000 Subject: [PATCH 01/11] Added functionality to attach a custom colormap function to a labelmap of X.Volume which can be used to draw the labelmap rather than using a color table file. The colormap is used in X.parser.reslice2 and X.renderer2D.prototype.render_. Not currently tried with the 3D renderer. --- io/parser.js | 12 ++++++++++-- objects/volume.js | 26 ++++++++++++++------------ visualization/renderer2D.js | 9 +++++++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/io/parser.js b/io/parser.js index af3020fb6..dcdaec153 100644 --- a/io/parser.js +++ b/io/parser.js @@ -759,7 +759,7 @@ X.parser.xyBBox = function(_solutionsXY){ * @return The target slice. * @static */ -X.parser.reslice2 = function(_sliceOrigin, _sliceXYSpacing, _sliceNormal, _color, _bbox, _IJKVolume, object, hasLabelMap, colorTable){ +X.parser.reslice2 = function(_sliceOrigin, _sliceXYSpacing, _sliceNormal, _color, _bbox, _IJKVolume, object, hasLabelMap, colorTable, colormap){ var sliceXY = new X.slice(); @@ -913,7 +913,7 @@ X.parser.reslice2 = function(_sliceOrigin, _sliceXYSpacing, _sliceNormal, _color // check for out of range and use the last label value in this case if (!lookupValue) { - lookupValue = [ 0, .61, 0, 0, 1 ]; + lookupValue = [ 0, 0.61, 0, 0, 1 ]; } @@ -923,6 +923,14 @@ X.parser.reslice2 = function(_sliceOrigin, _sliceXYSpacing, _sliceNormal, _color pixelValue_a = 255 * lookupValue[4]; } + else if (colormap) { + // colormap should be function taking value between 0 and 1 and returning rgba values [0,255] + var mapColor = colormap((pixval - object._min) / (object._max - object._min)); + pixelValue_r = mapColor[0]; + pixelValue_g = mapColor[1]; + pixelValue_b = mapColor[2]; + pixelValue_a = mapColor[3]; + } else { // normalization should not happen here, only in the shaders/canvas?? pixelValue_r = pixelValue_g = pixelValue_b = 255 * ((pixval - object._min )/ (object._max - object._min)); diff --git a/objects/volume.js b/objects/volume.js index f89753908..e466c6112 100644 --- a/objects/volume.js +++ b/objects/volume.js @@ -555,13 +555,14 @@ X.volume.prototype.slicing_ = function() { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map); + var colortable = this._labelmap._colortable ? this._labelmap._colortable._map : null; + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, colortable, this._labelmap.colormap); this._labelmap._children[xyz]._children[parseInt(currentIndex, 10)] = _sliceLabel; // add it to create the texture this._labelmap._children[xyz].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); if(this.hasLabelMap){ _slice._labelmap = _slice._texture; @@ -1473,7 +1474,7 @@ X.volume.prototype.sliceInfoChanged = function(index){ //attach labelmap if(this.hasLabelMap) { - var _sliceLabel = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map); + var _sliceLabel = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); this._labelmap._children[index]._children = []; this._labelmap._children[index]._children = new Array(this._childrenInfo[index]._nb); this._labelmap._children[index]._children[Math.floor(this._childrenInfo[index]._nb/2)] = _sliceLabel; @@ -1481,7 +1482,7 @@ X.volume.prototype.sliceInfoChanged = function(index){ this._labelmap._children[index].modified(); } - var _slice = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._IJKVolume, this, true, null); + var _slice = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); window.console.log('modified!'); @@ -1634,13 +1635,14 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map); + var colortable = this_labelmap._colortable ? this._labelmap._colortable._map : null; + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, colortable, this._labelmap.colormap || null); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap || null); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1679,13 +1681,13 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1723,13 +1725,13 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1768,13 +1770,13 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); _slice._children[0]._visible = false; if(this.hasLabelMap){ diff --git a/visualization/renderer2D.js b/visualization/renderer2D.js index 8877307a7..14d3bfc0d 100644 --- a/visualization/renderer2D.js +++ b/visualization/renderer2D.js @@ -1152,14 +1152,19 @@ X.renderer2D.prototype.render_ = function(picking, invoked) { if (_currentLabelMap) { // we have a label map here + if (_labelmap.colormap) { + var mapColor = _labelmap.colormap(_labelData[_index] / 255); + _label = [mapColor[0], mapColor[1], mapColor[2], mapColor[3]]; + } // check if all labels are shown or only one - if (_labelmapShowOnlyColor[3] == -255) { + else if (_labelmapShowOnlyColor[3] == -255) { // all labels are shown _label = [_labelData[_index], _labelData[_index + 1], _labelData[_index + 2], _labelData[_index + 3]]; - } else { + } + else { // show only the label which matches in color if (X.array.compare(_labelmapShowOnlyColor, _labelData, 0, _index, From 13be72895968ee714af623cc8826eaf42f008924 Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 8 Mar 2017 18:22:47 +0000 Subject: [PATCH 02/11] Fixed some bugs related to colormap when building XTK. Added a setter function to X.object to define a colormap function. Tested manually but still need to write some tests. --- io/parser.js | 6 +++--- objects/labelmap.js | 1 - objects/object.js | 38 ++++++++++++++++++++++++++++++++++++++ objects/volume.js | 26 +++++++++++++------------- 4 files changed, 54 insertions(+), 17 deletions(-) diff --git a/io/parser.js b/io/parser.js index dcdaec153..94ea7ae8c 100644 --- a/io/parser.js +++ b/io/parser.js @@ -1222,7 +1222,7 @@ X.parser.prototype.reslice = function(object) { _sliceOrigin[1] = object._childrenInfo[0]._solutionsLine[0][0][1] + object._childrenInfo[0]._sliceDirection[1]*Math.floor(object._childrenInfo[0]._nb/2); _sliceOrigin[2] = object._childrenInfo[0]._solutionsLine[0][0][2] + object._childrenInfo[0]._sliceDirection[2]*Math.floor(object._childrenInfo[0]._nb/2); - var _slice = X.parser.reslice2(_sliceOrigin, object._childrenInfo[0]._sliceXYSpacing, object._childrenInfo[0]._sliceNormal, object._childrenInfo[0]._color, object._BBox, object._IJKVolume, object, object.hasLabelMap, object._colorTable); + var _slice = X.parser.reslice2(_sliceOrigin, object._childrenInfo[0]._sliceXYSpacing, object._childrenInfo[0]._sliceNormal, object._childrenInfo[0]._color, object._BBox, object._IJKVolume, object, object.hasLabelMap, object._colorTable, object._colormap); if (object.hasLabelMap) { // if this object has a labelmap, @@ -1269,7 +1269,7 @@ X.parser.prototype.reslice = function(object) { _sliceOrigin[1] = object._childrenInfo[1]._solutionsLine[0][0][1] + object._childrenInfo[1]._sliceDirection[1]*Math.floor(object._childrenInfo[1]._nb/2); _sliceOrigin[2] = object._childrenInfo[1]._solutionsLine[0][0][2] + object._childrenInfo[1]._sliceDirection[2]*Math.floor(object._childrenInfo[1]._nb/2); - _slice = X.parser.reslice2(_sliceOrigin, object._childrenInfo[1]._sliceXYSpacing, object._childrenInfo[1]._sliceNormal, object._childrenInfo[1]._color, object._BBox, object._IJKVolume, object, object.hasLabelMap, object._colorTable); + _slice = X.parser.reslice2(_sliceOrigin, object._childrenInfo[1]._sliceXYSpacing, object._childrenInfo[1]._sliceNormal, object._childrenInfo[1]._color, object._BBox, object._IJKVolume, object, object.hasLabelMap, object._colorTable, object._colormap); if (object.hasLabelMap) { // if this object has a labelmap, @@ -1315,7 +1315,7 @@ X.parser.prototype.reslice = function(object) { _sliceOrigin[1] = object._childrenInfo[2]._solutionsLine[0][0][1] + object._childrenInfo[2]._sliceDirection[1]*Math.floor(object._childrenInfo[2]._nb/2); _sliceOrigin[2] = object._childrenInfo[2]._solutionsLine[0][0][2] + object._childrenInfo[2]._sliceDirection[2]*Math.floor(object._childrenInfo[2]._nb/2); - _slice = X.parser.reslice2(_sliceOrigin, object._childrenInfo[2]._sliceXYSpacing, object._childrenInfo[2]._sliceNormal, object._childrenInfo[2]._color, object._BBox, object._IJKVolume, object, object.hasLabelMap, object._colorTable); + _slice = X.parser.reslice2(_sliceOrigin, object._childrenInfo[2]._sliceXYSpacing, object._childrenInfo[2]._sliceNormal, object._childrenInfo[2]._color, object._BBox, object._IJKVolume, object, object.hasLabelMap, object._colorTable, object._colormap); if (object.hasLabelMap) { // if this object has a labelmap, diff --git a/objects/labelmap.js b/objects/labelmap.js index c1cec8fe4..93e2a9e21 100644 --- a/objects/labelmap.js +++ b/objects/labelmap.js @@ -97,7 +97,6 @@ X.labelmap.prototype.modified = function() { }; - /** * Show only the label with the given value or color (RGBA 0..1). If null is passed, * show all labels. diff --git a/objects/object.js b/objects/object.js index 8dfe7b567..3ec9ee98f 100755 --- a/objects/object.js +++ b/objects/object.js @@ -72,6 +72,14 @@ X.object = function(object) { * @protected */ this._children = new Array(); + + /** + * The colormap Function associated with this object. + * + * @type {Function} + * @protected + */ + this._colormap = null; /** * The color table of this object. @@ -179,6 +187,36 @@ X.object.prototype.copy_ = function(object) { }; +/** + * Associate a function with the _colormap property which can be used to color + * the labelmap based on normalized voxel values. + * + * @param {Function} A Function object taking a single argument between 0 and 1 and returning a + * length 4 Array containing rgba values between 0 and 255. + * @throws {Error} + * @public + */ +X.object.prototype.__defineSetter__('colormap', function(func) { + + if (!goog.isDefAndNotNull(func) || !goog.isFunction(func)) { + throw new Error('No function defined for colormap.'); + } + if (func.length != 1) { + throw new Error('Invalid number of arguments required for colormap function.'); + } else { + var rgba = func(1); + if (!goog.isArray(rgba) || rgba.length != 4) { + throw new Error('Return value of colormap is not a length 4 Array.'); + } else { + for (var i=0; i<4; i++) { + if (!goog.isNumber(rgba[i]) || rgba[i] < 0 || rgba[i] > 255) { + throw new Error('Return Array of colormap function contains one or more invalid rgba values.'); + } + } + } + } + this._colormap = func; +}); /** * The color table associated with this object. diff --git a/objects/volume.js b/objects/volume.js index e466c6112..0e24b38c2 100644 --- a/objects/volume.js +++ b/objects/volume.js @@ -556,13 +556,13 @@ X.volume.prototype.slicing_ = function() { //attach labelmap if(this.hasLabelMap){ var colortable = this._labelmap._colortable ? this._labelmap._colortable._map : null; - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, colortable, this._labelmap.colormap); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, colortable, this._labelmap._colormap); this._labelmap._children[xyz]._children[parseInt(currentIndex, 10)] = _sliceLabel; // add it to create the texture this._labelmap._children[xyz].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); if(this.hasLabelMap){ _slice._labelmap = _slice._texture; @@ -1474,7 +1474,7 @@ X.volume.prototype.sliceInfoChanged = function(index){ //attach labelmap if(this.hasLabelMap) { - var _sliceLabel = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); + var _sliceLabel = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap._colormap); this._labelmap._children[index]._children = []; this._labelmap._children[index]._children = new Array(this._childrenInfo[index]._nb); this._labelmap._children[index]._children[Math.floor(this._childrenInfo[index]._nb/2)] = _sliceLabel; @@ -1482,7 +1482,7 @@ X.volume.prototype.sliceInfoChanged = function(index){ this._labelmap._children[index].modified(); } - var _slice = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); + var _slice = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); window.console.log('modified!'); @@ -1635,14 +1635,14 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var colortable = this_labelmap._colortable ? this._labelmap._colortable._map : null; - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, colortable, this._labelmap.colormap || null); + var colortable = this._labelmap._colortable ? this._labelmap._colortable._map : null; + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, colortable, this._labelmap._colormap || null); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap || null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap || null); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1681,13 +1681,13 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap._colormap); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1725,13 +1725,13 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap._colormap); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1770,13 +1770,13 @@ X.volume.prototype.volumeRendering_ = function(direction) { //attach labelmap if(this.hasLabelMap){ - var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap.colormap); + var _sliceLabel = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap._colormap); this._labelmap._children[direction]._children[i] = _sliceLabel; // add it to create the texture this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap.colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); _slice._children[0]._visible = false; if(this.hasLabelMap){ From 2438aa27a670313ba551559ca6f9a13e5441b2e5 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 10 Mar 2017 17:54:47 +0000 Subject: [PATCH 03/11] Fixed a bug where colormap is passed to X.parser.reslice2 for the non-labelmap rendering. Also added to docs. --- io/parser.js | 1 + objects/volume.js | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/io/parser.js b/io/parser.js index 94ea7ae8c..2b1003a62 100644 --- a/io/parser.js +++ b/io/parser.js @@ -755,6 +755,7 @@ X.parser.xyBBox = function(_solutionsXY){ * @param {!X.object} object The X.volume. * @param {!boolean} hasLabelMap Volume has labelmap attached. * @param {goog.structs.Map} colorTable Associated color table. + * @param {Function} colormap Function mapping from labelmap pixel intensity to rgba. * * @return The target slice. * @static diff --git a/objects/volume.js b/objects/volume.js index 0e24b38c2..e75a5f658 100644 --- a/objects/volume.js +++ b/objects/volume.js @@ -562,7 +562,7 @@ X.volume.prototype.slicing_ = function() { this._labelmap._children[xyz].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, null); if(this.hasLabelMap){ _slice._labelmap = _slice._texture; @@ -1482,7 +1482,7 @@ X.volume.prototype.sliceInfoChanged = function(index){ this._labelmap._children[index].modified(); } - var _slice = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); + var _slice = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._IJKVolume, this, true, null, null); window.console.log('modified!'); @@ -1642,7 +1642,7 @@ X.volume.prototype.volumeRendering_ = function(direction) { this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap || null); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, null); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1687,7 +1687,7 @@ X.volume.prototype.volumeRendering_ = function(direction) { this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, null); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1731,7 +1731,7 @@ X.volume.prototype.volumeRendering_ = function(direction) { this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, null); _slice._children[0]._visible = false; if(this.hasLabelMap){ @@ -1776,7 +1776,7 @@ X.volume.prototype.volumeRendering_ = function(direction) { this._labelmap._children[direction].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[direction]._sliceXYSpacing, this._childrenInfo[direction]._sliceNormal, this._childrenInfo[direction]._color, this._BBox, this._IJKVolume, this, true, null, null); _slice._children[0]._visible = false; if(this.hasLabelMap){ From e23ac8b520a319983cb18e1229153966add00ac4 Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 6 Apr 2017 18:50:01 +0100 Subject: [PATCH 04/11] Added some getters and small changes useful for megatrack app --- objects/object.js | 11 +++++++++++ objects/volume.js | 16 ++++++++++++++-- visualization/renderer2D.js | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/objects/object.js b/objects/object.js index 3ec9ee98f..70f119477 100755 --- a/objects/object.js +++ b/objects/object.js @@ -266,6 +266,17 @@ X.object.prototype.__defineGetter__('children', function() { }); +/** + * Set the children of this object. + * + * @return {!Array} The children of this object which are again objects. + */ +X.object.prototype.__defineSetter__('children', function(newChildren) { + + this._children = newChildren; + +}); + /** * Fire a modified event for this object. * diff --git a/objects/volume.js b/objects/volume.js index 0e24b38c2..25aabb672 100644 --- a/objects/volume.js +++ b/objects/volume.js @@ -562,7 +562,7 @@ X.volume.prototype.slicing_ = function() { this._labelmap._children[xyz].modified(true); } - var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, this._labelmap._colormap); + var _slice = X.parser.reslice2(_sliceOrigin, this._childrenInfo[xyz]._sliceXYSpacing, this._childrenInfo[xyz]._sliceNormal, this._childrenInfo[xyz]._color, this._BBox, this._IJKVolume, this, true, null, null); if(this.hasLabelMap){ _slice._labelmap = _slice._texture; @@ -693,6 +693,18 @@ X.volume.prototype.__defineGetter__('dimensionsRAS', function() { }); +/** + * Get the RAScenter of this volume. + * + * @return {!Array} The center of this volume in RAS context. + * @public + */ +X.volume.prototype.__defineGetter__('RASCenter', function() { + + return this._RASCenter; + +}); + /** * Get the volume rendering setting of this X.volume. @@ -1474,7 +1486,7 @@ X.volume.prototype.sliceInfoChanged = function(index){ //attach labelmap if(this.hasLabelMap) { - var _sliceLabel = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable._map, this._labelmap._colormap); + var _sliceLabel = X.parser.reslice2(this._childrenInfo[index]._sliceOrigin, this._childrenInfo[index]._sliceXYSpacing, this._childrenInfo[index]._sliceNormal, this._childrenInfo[index]._color, this._BBox, this._labelmap._IJKVolume, this._labelmap, this._labelmap.hasLabelMap, this._labelmap._colortable ? this._labelmap._colortable._map : null, this._labelmap._colormap); this._labelmap._children[index]._children = []; this._labelmap._children[index]._children = new Array(this._childrenInfo[index]._nb); this._labelmap._children[index]._children[Math.floor(this._childrenInfo[index]._nb/2)] = _sliceLabel; diff --git a/visualization/renderer2D.js b/visualization/renderer2D.js index 14d3bfc0d..7983818be 100644 --- a/visualization/renderer2D.js +++ b/visualization/renderer2D.js @@ -1266,6 +1266,11 @@ X.renderer2D.prototype.render_ = function(picking, invoked) { var _buf = _x; _x = _y; _y = -_buf; + + //after rotation switch slice width and height + var tempSliceHeight = _sliceHeight; + _sliceHeight = 1.5 * _sliceWidth; //133;//_sliceWidth; + _sliceWidth = tempSliceHeight; } From 07f3892809c6fb382369fed0f4633de663a4262e Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 28 Apr 2017 06:51:26 +0100 Subject: [PATCH 05/11] Added functionality to view multiple labelmaps in 2D renderer --- io/parser.js | 34 +++-- objects/volume.js | 20 +++ visualization/renderer2D.js | 255 ++++++++++++++++++++++++++---------- 3 files changed, 229 insertions(+), 80 deletions(-) diff --git a/io/parser.js b/io/parser.js index 94ea7ae8c..22dad5f30 100644 --- a/io/parser.js +++ b/io/parser.js @@ -923,14 +923,14 @@ X.parser.reslice2 = function(_sliceOrigin, _sliceXYSpacing, _sliceNormal, _color pixelValue_a = 255 * lookupValue[4]; } - else if (colormap) { - // colormap should be function taking value between 0 and 1 and returning rgba values [0,255] - var mapColor = colormap((pixval - object._min) / (object._max - object._min)); - pixelValue_r = mapColor[0]; - pixelValue_g = mapColor[1]; - pixelValue_b = mapColor[2]; - pixelValue_a = mapColor[3]; - } +// else if (colormap) { +// // colormap should be function taking value between 0 and 1 and returning rgba values [0,255] +// var mapColor = colormap((pixval - object._min) / (object._max - object._min)); +// pixelValue_r = mapColor[0]; +// pixelValue_g = mapColor[1]; +// pixelValue_b = mapColor[2]; +// pixelValue_a = mapColor[3]; +// } else { // normalization should not happen here, only in the shaders/canvas?? pixelValue_r = pixelValue_g = pixelValue_b = 255 * ((pixval - object._min )/ (object._max - object._min)); @@ -1163,7 +1163,8 @@ X.parser.prototype.reslice = function(object) { // ------------------------------------------ // SETUP LABEL MAPS AND COLOR TABLES // ------------------------------------------ - object.hasLabelMap = object._labelmap != null; + object.hasLabelMap = object._labelmap != null && !goog.isArray(object._labelmap); + object.hasLabelMapArray = object._labelmap != null && goog.isArray(object._labelmap); if (object._colortable) { object._colorTable = object._colortable._map; } @@ -1229,6 +1230,11 @@ X.parser.prototype.reslice = function(object) { // we have it loaded at this point (for sure) // ..so we can attach it as the second texture to this slice _slice._labelmap = object._labelmap._children[0]._children[Math.floor(object._childrenInfo[0]._nb/2)]._texture; + } else if (object.hasLabelMapArray) { + _slice._labelmap = []; + for (var i=0; i Date: Fri, 12 May 2017 17:23:57 +0100 Subject: [PATCH 06/11] Minor updates for the multiple labelmap display --- objects/slice.js | 7 +++++++ visualization/renderer2D.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/objects/slice.js b/objects/slice.js index bb1bc085c..6f87bbd71 100644 --- a/objects/slice.js +++ b/objects/slice.js @@ -221,6 +221,13 @@ X.slice.prototype.__defineGetter__('right', function() { }); +/** + * Get the labelmap of this slice. + */ +X.slice.prototype.__defineGetter__('labelmap', function() { + return this._labelmap +}); + /** * Setup this X.slice and create it. diff --git a/visualization/renderer2D.js b/visualization/renderer2D.js index 4a54a50d3..deb43e720 100644 --- a/visualization/renderer2D.js +++ b/visualization/renderer2D.js @@ -1371,7 +1371,7 @@ X.renderer2D.prototype.render_ = function(picking, invoked) { //after rotation switch slice width and height var tempSliceHeight = _sliceHeight; - _sliceHeight = 1.5 * _sliceWidth; //133;//_sliceWidth; + _sliceHeight = 1.45 * _sliceWidth; //133;//_sliceWidth; _sliceWidth = tempSliceHeight; } From d8f90c63cb0c82c2b92e8fb02269ab6e64e57554 Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 6 Jul 2017 11:09:34 +0100 Subject: [PATCH 07/11] Fixed bug in renderer2D where only max of 4 labelmaps could be used at same time as thresholding --- io/loader.js | 3 +-- visualization/renderer2D.js | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/io/loader.js b/io/loader.js index 5c96b8551..f11f87fbd 100644 --- a/io/loader.js +++ b/io/loader.js @@ -239,10 +239,9 @@ X.loader.prototype.load = function(container, object) { // configure the URL request.open('GET', filepath, true); request.responseType = 'arraybuffer'; - + // .. and GO! request.send(null); - }; diff --git a/visualization/renderer2D.js b/visualization/renderer2D.js index deb43e720..90a77559a 100644 --- a/visualization/renderer2D.js +++ b/visualization/renderer2D.js @@ -1162,6 +1162,13 @@ X.renderer2D.prototype.render_ = function(picking, invoked) { // default color and label is just transparent var _color = [0, 0, 0, 0]; var _label = [0, 0, 0, 0]; + if (goog.isArray(_currentLabelMap)) { + _label = []; + for (var i=0; i<_currentLabelMap.length; i++) { + _label.push([0,0,0,0]); + } + } + var _fac1 = _volume._max - _volume._min; // grab the pixel intensity From 1fa8d5b72f8d4980ab0b0167a1d346c910712781 Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 15 Jan 2018 16:28:05 +0000 Subject: [PATCH 08/11] Now firing parseComplete event after parsing is complete --- io/loader.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/io/loader.js b/io/loader.js index f11f87fbd..db9a9f894 100644 --- a/io/loader.js +++ b/io/loader.js @@ -292,6 +292,11 @@ X.loader.prototype.parse = function(request, container, object) { // call the parse function and pass in the container, the object and the // data stream and some additional value _parser.parse(container, object, _data, flags); + + var event = document.createEvent("HTMLEvents"); + event.initEvent("parsingComplete", true, true); + event.eventName = "parsingComplete"; + document.documentElement.dispatchEvent(event); }.bind(this), 100); From aa72889e5b62675fb297d17423d77aff5de5465c Mon Sep 17 00:00:00 2001 From: Richard Date: Thu, 2 Aug 2018 15:36:04 +0100 Subject: [PATCH 09/11] Delay firing modified event on the volume until all loading jobs are complete --- io/loader.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/io/loader.js b/io/loader.js index db9a9f894..535c40019 100644 --- a/io/loader.js +++ b/io/loader.js @@ -327,12 +327,14 @@ X.loader.prototype.complete = function(event) { // .. but mark the container as dirty since its content changed container._dirty = true; - - // fire the modified event on the object - object.modified(); - + // mark the loading job as completed this._jobs.set(container._id, true); + + // fire the modified event on the object if all loading jobs complete + if (this.completed()) { + object.modified(); + } }.bind(this), 100); From 98dd8ba42487f7e0f8704c3ceeed94f2de9d20d3 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 24 Aug 2018 15:53:00 +0100 Subject: [PATCH 10/11] Added pauseRendering function --- visualization/renderer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/visualization/renderer.js b/visualization/renderer.js index 1879e836c..d896f7733 100644 --- a/visualization/renderer.js +++ b/visualization/renderer.js @@ -1212,6 +1212,10 @@ X.renderer.prototype.render_ = function(picking, invoked) { }; +X.renderer.prototype.pauseRendering = function() { + window.cancelAnimationFrame(this._AnimationFrameID); +}; + /** * Destroy this renderer. * From 0499f1a85e26d7cbf515774fc2f125487eedcc69 Mon Sep 17 00:00:00 2001 From: Richard Stones Date: Sat, 1 Jun 2019 07:11:40 +0100 Subject: [PATCH 11/11] Making some properties public for use outside xtk --- math/vector4.js | 175 ++++++++++++++++++++++++++++++++++++ objects/volume.js | 36 ++++++++ visualization/renderer3D.js | 1 + 3 files changed, 212 insertions(+) create mode 100644 math/vector4.js diff --git a/math/vector4.js b/math/vector4.js new file mode 100644 index 000000000..ea80bb6ca --- /dev/null +++ b/math/vector4.js @@ -0,0 +1,175 @@ +/* + * + * xxxxxxx xxxxxxx + * x:::::x x:::::x + * x:::::x x:::::x + * x:::::xx:::::x + * x::::::::::x + * x::::::::x + * x::::::::x + * x::::::::::x + * x:::::xx:::::x + * x:::::x x:::::x + * x:::::x x:::::x + * THE xxxxxxx xxxxxxx TOOLKIT + * + * http://www.goXTK.com + * + * Copyright (c) 2012 The X Toolkit Developers + * + * The X Toolkit (XTK) is licensed under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + * + * "Free software" is a matter of liberty, not price. + * "Free" as in "free speech", not as in "free beer". + * - Richard M. Stallman + * + * + */ +// provides +goog.provide('X.vector4'); + +// requires +goog.require('goog.vec.Vec4'); + + +// expose the following goog.math.Vec3 functionality +/** + * @constructor + * @see goog.math.Vec3 + */ +X.vector4 = goog.vec.Vec4; + + +// /** +// * @see goog.math.Vec3.prototype.clone +// */ +// X.vector.prototype.clone = goog.math.Vec3.prototype.clone; +// +// +// /** +// * @see goog.math.Vec3.prototype.magnitude +// */ +// X.vector.prototype.magnitude = goog.math.Vec3.prototype.magnitude; +// +// +// /** +// * @see goog.math.Vec3.prototype.scale +// */ +// X.vector.prototype.scale = goog.math.Vec3.prototype.scale; +// +// +// /** +// * @see goog.math.Vec3.prototype.invert +// */ +// X.vector.prototype.invert = goog.math.Vec3.prototype.invert; +// +// +// /** +// * @see goog.math.Vec3.prototype.add +// */ +// X.vector.prototype.add = goog.math.Vec3.prototype.add; +// +// +// /** +// * @see goog.math.Vec3.prototype.subtract +// */ +// X.vector.prototype.subtract = goog.math.Vec3.prototype.subtract; +// +// +// /** +// * Normalize the vector. The goog.math.Vec3.prototype.normalize +// * did not check on a magnitude of 0 resulting in an error. +// * +// * @return {!X.vector|!goog.math.Vec3} The normalized vector. +// */ +// X.vector.prototype.normalize = function() { +// // add a special check if the magnitude is 0 +// var _magnitude = this.magnitude(); +// if (_magnitude == 0) { +// return this.scale(0); +// } +// return this.scale(1 / _magnitude); +// }; +// +// +// /** +// * @see goog.math.Vec3.dot +// */ +// X.vector.dot = goog.math.Vec3.dot; +// +// +// /** +// * @see goog.math.Vec3.cross +// */ +// X.vector.cross = goog.math.Vec3.cross; +// +// +// /** +// * @see goog.math.Vec3.distance +// */ +// X.vector.distance = goog.math.Vec3.distance; +// +// +// /** +// * @see goog.math.Vec3.lerp +// */ +// X.vector.lerp = goog.math.Vec3.lerp; + +// // now we need to make sure we can access the x,y,z +// // components of a goog.math.Vec3 which might be renamed +// // during the compilation. we don't want to modify the goog.math.Vec3 +// // class so this is the easiest workaround. +// /** +// * Get the x component of this vector. +// * +// * @return {number} The x component of this vector. +// * @public +// */ +// X.vector4.prototype.__defineGetter__('xx', function() { +// +// return this.x; +// +// }); +// +// +// /** +// * Get the y component of this vector. +// * +// * @return {number} The y component of this vector. +// * @public +// */ +// X.vector4.prototype.__defineGetter__('yy', function() { +// +// return this.y; +// +// }); +// +// +// /** +// * Get the z component of this vector. +// * +// * @return {number} The z component of this vector. +// * @public +// */ +// X.vector4.prototype.__defineGetter__('zz', function() { +// +// return this.z; +// +// }); + + +goog.exportSymbol('X.vector4', X.vector4); +goog.exportSymbol('X.vector4.createFloat32FromValues', X.vector4.createFloat32FromValues); +goog.exportSymbol('X.vector4.createFloat32', X.vector4.createFloat32); +// goog.exportSymbol('X.vector.prototype.clone', X.vector.prototype.clone); +// goog.exportSymbol('X.vector.prototype.magnitude', X.vector.prototype.magnitude); +// goog.exportSymbol('X.vector.prototype.scale', X.vector.prototype.scale); +// goog.exportSymbol('X.vector.prototype.invert', X.vector.prototype.invert); +// goog.exportSymbol('X.vector.prototype.normalize', X.vector.prototype.normalize); +// goog.exportSymbol('X.vector.prototype.add', X.vector.prototype.add); +// goog.exportSymbol('X.vector.prototype.subtract', X.vector.prototype.subtract); +// goog.exportSymbol('X.vector.dot', X.vector.dot); +// goog.exportSymbol('X.vector.cross', X.vector.cross); +// goog.exportSymbol('X.vector.distance', X.vector.distance); +// goog.exportSymbol('X.vector.lerp', X.vector.lerp); \ No newline at end of file diff --git a/objects/volume.js b/objects/volume.js index 8e313bc49..593d54b73 100644 --- a/objects/volume.js +++ b/objects/volume.js @@ -717,6 +717,42 @@ X.volume.prototype.__defineGetter__('RASCenter', function() { }); +/** + * Get the RAS origin of this volume. + * + * @return {!Array} The origin of this volume in RAS coords. + * @public + */ +X.volume.prototype.__defineGetter__('RASOrigin', function() { + + return this._RASOrigin; + +}); + +/** + * Get the RAS to IJK transformation of this volume. + * + * @return {!Array} The RAS to IJK transformation + * @public + */ +X.volume.prototype.__defineGetter__('RASToIJK', function() { + + return this._RASToIJK; + +}); + +/** + * Get the IJK volume. + * + * @return {!Array} The IJK volume + * @public + */ +X.volume.prototype.__defineGetter__('IJKVolume', function() { + + return this._IJKVolume; + +}); + /** * Get the volume rendering setting of this X.volume. diff --git a/visualization/renderer3D.js b/visualization/renderer3D.js index a0c5cc0d3..3039de76f 100755 --- a/visualization/renderer3D.js +++ b/visualization/renderer3D.js @@ -2417,3 +2417,4 @@ goog.exportSymbol('X.renderer3D.prototype.pick', X.renderer3D.prototype.pick); goog.exportSymbol('X.renderer3D.prototype.pick3d', X.renderer3D.prototype.pick3d); goog.exportSymbol('X.renderer3D.prototype.afterRender', X.renderer3D.prototype.afterRender); goog.exportSymbol('X.renderer3D.prototype.resize', X.renderer3D.prototype.resize); +goog.exportSymbol('X.renderer3D.prototype.pauseRendering', X.renderer3D.prototype.pauseRendering);