function endDrawing(eventData, handleNearby) {
  var toolData = (0, _toolState.getToolState)(eventData.element, toolType);

  if (!toolData) {
    return;
  }

  var config = freehand.getConfiguration();
  var data = toolData.data[config.currentTool];
  var deleteData = false;

  if (!data) {
    return;
  }

  data.active = false;
  data.highlight = false;
  data.handles.invalidHandlePlacement = false;

  // Connect the end handle to the origin handle
  if (handleNearby !== undefined) {
    if (data.handles.length > 2) {
      data.handles[config.currentHandle - 1].lines.push(data.handles[0]);
    } else {
      deleteData = true;
    }
  }

  if (config.modifying) {
    config.modifying = false;
    data.invalidated = true;
  }

  // Reset the current handle
  config.currentHandle = 0;
  config.currentTool = -1;
  config.activePencilMode = false;
  data.canComplete = false;

  if (deleteData) {
    (0, _toolState.removeToolState)(eventData.element, toolType, data);
  } else {
    var seriesModule = _externalModules2.default.cornerstone.metaData.get('generalSeriesModule', eventData.image.imageId);
    var modality = void 0;

    if (seriesModule) {
      modality = seriesModule.modality;
    }

    var _getColRowPixelSpacin = (0, _getColRowPixelSpacing2.default)(eventData.image),
        rowPixelSpacing = _getColRowPixelSpacin.rowPixelSpacing,
        colPixelSpacing = _getColRowPixelSpacin.colPixelSpacing;

    calculateStatistics(data, eventData.element, eventData.image, modality, rowPixelSpacing, colPixelSpacing);

    fireCompleted(eventData.element, data);
  }

  _externalModules2.default.cornerstone.updateImage(eventData.element);
}
/**
* Ends the active drawing loop and completes the polygon.
*
* @param {Object} eventData - data object associated with an event.
* @param {Object} handleNearby - the handle nearest to the mouse cursor.
*/
Ends the active drawing loop and completes the polygon.
Ends the active drawing loop and completes the polygon .
function endDrawing(eventData, handleNearby) {
  var toolData = (0, _toolState.getToolState)(eventData.element, toolType);
  if (!toolData) {
    return;
  }
  var config = freehand.getConfiguration();
  var data = toolData.data[config.currentTool];
  var deleteData = false;
  if (!data) {
    return;
  }
  data.active = false;
  data.highlight = false;
  data.handles.invalidHandlePlacement = false;
  if (handleNearby !== undefined) {
    if (data.handles.length > 2) {
      data.handles[config.currentHandle - 1].lines.push(data.handles[0]);
    } else {
      deleteData = true;
    }
  }
  if (config.modifying) {
    config.modifying = false;
    data.invalidated = true;
  }
  config.currentHandle = 0;
  config.currentTool = -1;
  config.activePencilMode = false;
  data.canComplete = false;
  if (deleteData) {
    (0, _toolState.removeToolState)(eventData.element, toolType, data);
  } else {
    var seriesModule = _externalModules2.default.cornerstone.metaData.get('generalSeriesModule', eventData.image.imageId);
    var modality = void 0;
    if (seriesModule) {
      modality = seriesModule.modality;
    }
    var _getColRowPixelSpacin = (0, _getColRowPixelSpacing2.default)(eventData.image),
        rowPixelSpacing = _getColRowPixelSpacin.rowPixelSpacing,
        colPixelSpacing = _getColRowPixelSpacin.colPixelSpacing;
    calculateStatistics(data, eventData.element, eventData.image, modality, rowPixelSpacing, colPixelSpacing);
    fireCompleted(eventData.element, data);
  }
  _externalModules2.default.cornerstone.updateImage(eventData.element);
}
function endDrawing ( eventData , handleNearby ) { var toolData = ( 0 , _toolState . getToolState ) ( eventData . element , toolType ) ; if ( ! toolData ) { return ; } var config = freehand . getConfiguration ( ) ; var data = toolData . data [ config . currentTool ] ; var deleteData = false ; if ( ! data ) { return ; } data . active = false ; data . highlight = false ; data . handles . invalidHandlePlacement = false ; if ( handleNearby !== undefined ) { if ( data . handles . length > 2 ) { data . handles [ config . currentHandle - 1 ] . lines . push ( data . handles [ 0 ] ) ; } else { deleteData = true ; } } if ( config . modifying ) { config . modifying = false ; data . invalidated = true ; } config . currentHandle = 0 ; config . currentTool = - 1 ; config . activePencilMode = false ; data . canComplete = false ; if ( deleteData ) { ( 0 , _toolState . removeToolState ) ( eventData . element , toolType , data ) ; } else { var seriesModule = _externalModules2 . default . cornerstone . metaData . get ( 'generalSeriesModule' , eventData . image . imageId ) ; var modality = void 0 ; if ( seriesModule ) { modality = seriesModule . modality ; } var _getColRowPixelSpacin = ( 0 , _getColRowPixelSpacing2 . default ) ( eventData . image ) , rowPixelSpacing = _getColRowPixelSpacin . rowPixelSpacing , colPixelSpacing = _getColRowPixelSpacin . colPixelSpacing ; calculateStatistics ( data , eventData . element , eventData . image , modality , rowPixelSpacing , colPixelSpacing ) ; fireCompleted ( eventData . element , data ) ; } _externalModules2 . default . cornerstone . updateImage ( eventData . element ) ; }
Ends the active drawing loop and completes the polygon.
Ends the active drawing loop and completes the polygon .
// Connect the end handle to the origin handle // Reset the current handle