static/js/render.js
/**
 * Let user draw polygon to select a region of contigs.
 * @function polygonSelect
 * @param {Object} mo - main object
 * @param {boolean} shift - whether Shift key is processed
 */
Let user draw polygon to select a region of contigs.
@function polygonSelect
@param {Object} mo - main object
@param {boolean} shift - whether Shift key is processed
Let user draw polygon to select a region of contigs . @function polygonSelect @param { Object } mo - main object @param { boolean } shift - whether Shift key is processed
function polygonSelect(mo, shift) {
  let n = mo.cache.nctg;
  if (!n) return;
  const stat = mo.stat,
        oray = mo.oray;
  const btn = byId('polygon-btn');
  const title = btn.title;
  btn.title = btn.getAttribute('data-title');
  btn.setAttribute('data-title', title);
  btn.classList.toggle('pressed');
  if (!stat.drawing) {
    stat.polygon = [];
    stat.drawing = true;
  }
  else {
    const w = oray.width,
          h = oray.height;
    oray.getContext('2d').clearRect(0, 0, w, h);
    const X = mo.trans.x,
          Y = mo.trans.y;
    const mask = mo.masked;
    const ctgs = [];
    for (let i = 0; i < n; i++) {
      if (!mask[i]) {
        if (pnpoly(X[i] * w, Y[i] * h, stat.polygon)) ctgs.push(i);
      }
    }
    stat.polygon = [];
    stat.drawing = false;
    treatSelection(ctgs, mo, shift);
  }
}
function polygonSelect ( mo , shift ) { let n = mo . cache . nctg ; if ( ! n ) return ; const stat = mo . stat , oray = mo . oray ; const btn = byId ( 'polygon-btn' ) ; const title = btn . title ; btn . title = btn . getAttribute ( 'data-title' ) ; btn . setAttribute ( 'data-title' , title ) ; btn . classList . toggle ( 'pressed' ) ; if ( ! stat . drawing ) { stat . polygon = [ ] ; stat . drawing = true ; } else { const w = oray . width , h = oray . height ; oray . getContext ( '2d' ) . clearRect ( 0 , 0 , w , h ) ; const X = mo . trans . x , Y = mo . trans . y ; const mask = mo . masked ; const ctgs = [ ] ; for ( let i = 0 ; i < n ; i ++ ) { if ( ! mask [ i ] ) { if ( pnpoly ( X [ i ] * w , Y [ i ] * h , stat . polygon ) ) ctgs . push ( i ) ; } } stat . polygon = [ ] ; stat . drawing = false ; treatSelection ( ctgs , mo , shift ) ; } }
Let user draw polygon to select a region of contigs.
Let user draw polygon to select a region of contigs .
// change button appearance // start drawing // finish drawing // find contigs within polygon // treat selected contigs