function geometryToolAction(p, shapeName) {
var start, gridStart, end;
var tool = activateTool(`${shapeName}Tool`, p);
selection.clear(p);
document.dispatchEvent(new CustomEvent("formChange"));
tool.onMouseMove = function (event) {
tmpGrp(p).removeChildren();
start = null;
var highLightP = Inv.getClosest(event.point, p);
if (highLightP) {
highlightPoint(highLightP, p);
start = highLightP;
}
};
tool.onMouseDown = function (event) {
[start, gridStart] = recordStart(event, start, p);
};
tool.onMouseDrag = function (event) {
end = dragGeometry(event, p, start, gridStart, shapeName);
};
tool.onMouseUp = function (event) {
var shape = addGeometry(end, p, gridStart, shapeName);
console.log(shape);
selectToolAction(p);
selection.push(shape);
Inv.addPath(shape, p);
document.dispatchEvent(new CustomEvent("formChange"));
};
}