* @desc Dispatches paint/erase commands to the annotation volume and to the server for broadcast
* @param {integer} u The number of the user producing the paint event. u === -1 means that the paint event was produced by a different user, and it is not broadcasted (to prevent loops)
* @param {character} c The paint command: le, lf, e, f.
* @param {integer} x X coordinate in slice space
* @param {integer} y Y coordinate in slice space
* @param {Object} usr User object for the current user. Contains the painting value, view and slice
* @desc Paints a series of voxels as indicated in an array. This function is exclusively used for undoing
* @param {Array} voxels Array where each object contains a voxel index and a voxel value. The voxel index goes from 0 to dim[0]*dim[1]*dim[2]-1
* @returns {void}
*/
paintvol:functionpaintvol(voxels){
constme=AtlasMakerWidget;
leti;
for(i=0;i<voxels.length;i++){
// ind: voxel index
// val: voxel delta-value, such that -=val undoes
const[ind,val]=voxels[i];
me.atlas.data[ind]=val;
}
me.drawImages();
},
/**
* @function fill
* @desc Fills a 2D slice in an annotation volume starting at coordinates x, y, z replacing all the connected pixels of same value as the original value at x, y, z
* @param {number} x X coordinate in voxel space
* @param {number} y Y coordinate in voxel space
* @param {number} z Z coordinate in voxel space
* @param {number} val Value to fill with
* @param {string} myView The stereotaxic plane along which to fill: either 'cor', 'axi' or 'sag'
* @returns {void}
*/
fill:functionfill(x,y,z,val,myView){
constme=AtlasMakerWidget;
const{atlas}=me;
constQ=[];
letleft,n,right;
letmax=0;
constbval=atlas.data[me.slice2index(x,y,z,myView)];// background-value: value of the voxel where the click occurred
* @desc Convert slice coordinates into voxel coordinates
* @param {number} mx X coordinate
* @param {number} my Y coordinate
* @param {number} mz Z coordinate
* @param {string} myView String representing the view: 'sag', 'cor' or 'axi'
* @returns {array} An array [x,y,z,i] where the first 3 values are the voxel coordinates and the 4th value is the voxel index (value from 0 to dim[0]*dim[1]*dim[2]-1)