Skip to content
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
1 change: 1 addition & 0 deletions cortex/defaults.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ specularity = 1.0
overlayscale = 1
anim_speed = 2
bumpy_flatmap = false
allow_tilt = false

[curvature]
contrast = 0.25
Expand Down
22 changes: 16 additions & 6 deletions cortex/webgl/resources/js/movement.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var jsplot = (function (module) {

this._momentum = {change:[0,0]};
this._state = STATE.NONE;
this.allowTilt = false;

this.twodbutton = $(document.createElement('button'));
this.twodbutton.attr('id', 'twodbutton');
Expand Down Expand Up @@ -59,7 +60,7 @@ var jsplot = (function (module) {
if (this._state != STATE.NONE) {
if (this._state == STATE.ROTATE)
func = this.rotate
else if (this._state == STATE.PAN && this.mix == 1)
else if (this._state == STATE.PAN && this.mix == 1 && this.allowTilt)
func = this.rotate
else if (this._state == STATE.PAN)
func = this.pan
Expand Down Expand Up @@ -142,19 +143,28 @@ var jsplot = (function (module) {

az = az < 0 ? az + 360 : az % 360;

if ( this.mix == 1.0 )
this._flatazimuth = az;
else
if ( this.mix == 1.0 ) {
if (this.allowTilt)
this._flatazimuth = az;
else
this._flatazimuth = 180;
this.azimuth = this._flatazimuth;
} else {
this._foldedazimuth = az;
this.azimuth = az;
this.azimuth = az;
}
this.update2Dbutton();
}
module.LandscapeControls.prototype.setAltitude = function(alt) {
if (alt === undefined)
return this.altitude;

if ( this.mix == 1.0 ) {
this._flataltitude = Math.min(Math.max(alt, 0.1), 75);
if (this.allowTilt) {
this._flataltitude = Math.min(Math.max(alt, 0.1), 75);
} else {
this._flataltitude = 0.1;
}
this.altitude = this._flataltitude
}
else {
Expand Down
7 changes: 7 additions & 0 deletions cortex/webgl/resources/js/mriview.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ var mriview = (function(module) {
this.controls.setMix(evt.flat);
}.bind(this);

//allowTilt function to attach to surface when it's added
this._allowTilt = function(evt){
this.controls.allowTilt = evt.value;
}.bind(this);

//Initialize all the html
$(this.object).html($("#mriview_html").html())

Expand Down Expand Up @@ -625,6 +630,7 @@ var mriview = (function(module) {
//Sets the slicing surface used to visualize the data
var surf = new surftype(this.active, opts);
surf.addEventListener("mix", this._mix);
surf.addEventListener("allowTilt", this._allowTilt);

this.surfs.push(surf);
this.root.add(surf.object);
Expand Down Expand Up @@ -791,6 +797,7 @@ var mriview = (function(module) {
this.active.removeEventListener("attribute", this.surfs[i]._attrib);
this.removeEventListener("resize", this.surfs[i]._resize);
this.surfs[i].removeEventListener("mix", this._mix);
this.surfs[i].removeEventListener("allowTilt", this._allowTilt);

this.root.remove(this.surfs[i].object);
} else
Expand Down
9 changes: 8 additions & 1 deletion cortex/webgl/resources/js/mriview_surface.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var mriview = (function(module) {
"fiducial surface": {action: this.to_fiducial_surface.bind(this), key: 'u', help: "Fiducial surface"},
"WM surface": {action: this.to_white_matter_surface.bind(this), key: 'y', help: "White matter surface"},
bumpy_flatmap: {action:[this.uniforms.bumpyflat, "value"]},
allow_tilt: {action:[this.uniforms.allowtilt, "value"]},
allow_tilt: {action:[this, "setAllowTilt"]},
equivolume: {action:[this, "setEquivolume"]},
changeDepth: {action: this.changeDepth.bind(this), wheel: true, modKeys: ['altKey'], hidden: true, help:'Change depth'},
changeInflation: {action: this.changeInflation.bind(this), wheel: true, modKeys: ['shiftKey'], hidden: true, help:'Change inflation'},
Expand Down Expand Up @@ -669,6 +669,13 @@ var mriview = (function(module) {
this.resetShaders();
}

module.Surface.prototype.setAllowTilt = function(val) {
if (val === undefined)
return this.uniforms.allowtilt.value;
this.uniforms.allowtilt.value = val;
this.dispatchEvent({type:'allowTilt', value:val});
}

module.Surface.prototype._makeMesh = function(geom, shader) {
//Creates the mesh object given the geometry and shader
var mesh = new THREE.Mesh(geom, shader);
Expand Down