diff --git a/web/app/sketcher/sketcher-app.js b/web/app/sketcher/sketcher-app.js index acf1525f..b6adec79 100644 --- a/web/app/sketcher/sketcher-app.js +++ b/web/app/sketcher/sketcher-app.js @@ -45,7 +45,7 @@ function App2D() { }); $(document).on('mousemove', '#viewer', (e) => { let coord = this.viewer.screenToModel(e); - $('.coordinates-info').text(coord.x.toFixed(3) + " : " + coord.y.toFixed(3)); + $('.coordinates-info').text(this.viewer.roundToPrecision(coord.x) + " : " + this.viewer.roundToPrecision(coord.y)); }); this.terminalHandler = undefined; this.terminal = new Terminal(this.commandsWin, (command) => this.handleTerminalInput(command), () => this.getAllCommandList()); @@ -376,7 +376,7 @@ App2D.prototype.bindToolsToTerminal = function() { })(); this.viewer.bus.subscribe('tool-message', (message) => { this.terminal.print(message); - $('.tool-message').text(': ' + message); + $('.tool-message').text(message); }); }; diff --git a/web/app/sketcher/tools/origin.js b/web/app/sketcher/tools/origin.js index a7825532..ad1c74ce 100644 --- a/web/app/sketcher/tools/origin.js +++ b/web/app/sketcher/tools/origin.js @@ -25,7 +25,7 @@ export class ReferencePointTool extends Tool { let p = needSnap ? this.viewer.snapped.pop() : this.viewer.screenToModel(e); this.viewer.referencePoint.x = p.x; this.viewer.referencePoint.y = p.y; - this.sendMessage(p.x + ', ' + p.y); + this.sendPickedMessage(p.x, p.y); this.viewer.refresh(); this.viewer.toolManager.releaseControl(); }; diff --git a/web/app/sketcher/tools/tool.js b/web/app/sketcher/tools/tool.js index b094e9da..ee7ebeed 100644 --- a/web/app/sketcher/tools/tool.js +++ b/web/app/sketcher/tools/tool.js @@ -29,6 +29,11 @@ export class Tool { sendMessage(text) { this.viewer.bus.notify('tool-message', text); }; + + sendPickedMessage(x, y) { + this.sendMessage('picked: ' + this.viewer.roundToPrecision(x) + " : " + this.viewer.roundToPrecision(y)); + }; + } const VECTOR_PATTERNS = /^(@)?(.+)(,|<)(.+)$/; diff --git a/web/app/sketcher/viewer2d.js b/web/app/sketcher/viewer2d.js index 6297c4e4..2ee81ebf 100644 --- a/web/app/sketcher/viewer2d.js +++ b/web/app/sketcher/viewer2d.js @@ -65,7 +65,12 @@ function setStyle(style, ctx, scale) { /** @constructor */ function Viewer(canvas, IO) { - + + // 1/1000'' aka 1 mil is a standard precision for the imperial system(for engeneering) + // this precision also covers the metric system which is supposed to be ~0.01 + // this field is used only for displaying purposes now, although in future it could be + // used to keep all internal data with such precision transforming the input from user + this.presicion = 3; this.canvas = canvas; this.params = new Parameters(); this.io = new IO(this); @@ -122,6 +127,10 @@ function Viewer(canvas, IO) { this.refresh(); } +Viewer.prototype.roundToPrecision = function(value) { + return value.toFixed(this.presicion); +}; + Viewer.prototype.validateGeom = function() { for (var i = 0; i < this.layers.length; i++) { var objs = this.layers[i].objects;