mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 09:52:34 +01:00
add tool info text in the bottom of the viewer
This commit is contained in:
parent
456d67c537
commit
6ac8939595
4 changed files with 18 additions and 4 deletions
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 = /^(@)?(.+)(,|<)(.+)$/;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue