jsketcher/web/app/sketcher/tools/point.js
Val Erastov (xibyte) e11c1f7f4a geom module
2020-07-19 22:37:24 -07:00

36 lines
812 B
JavaScript

import {EndPoint} from '../shapes/point'
import {Tool} from './tool'
export class AddPointTool extends Tool {
constructor(viewer) {
super('geom.point', viewer);
}
restart() {
this.sendSpecifyPointHint();
}
mouseup(e) {
const input = this.viewer.screenToModel(e);
this.processPointInput(input);
}
processCommand(command) {
const result = Tool.ParseVector(this.viewer.referencePoint, command);
if(typeof result === 'string') {
return result;
}
this.processPointInput(result);
}
processPointInput(input) {
this.viewer.historyManager.checkpoint();
const p = new EndPoint(input.x, input.y);
const layer = this.viewer.activeLayer;
layer.add(p);
this.pointPicked(input.x, input.y);
this.viewer.refresh();
this.restart();
}
}