From aba7cfb2b81a3c005246d70e3ee0402fe7ec4746 Mon Sep 17 00:00:00 2001 From: "SOLARPRO1\\netze" Date: Tue, 18 Apr 2023 17:29:07 +0300 Subject: [PATCH] Bug fix - don't allow dim tool to stay on the screen --- web/app/sketcher/tools/dim.js | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/web/app/sketcher/tools/dim.js b/web/app/sketcher/tools/dim.js index 3c658ce4..8c8bfde7 100644 --- a/web/app/sketcher/tools/dim.js +++ b/web/app/sketcher/tools/dim.js @@ -6,14 +6,14 @@ import { VDimension, } from '../shapes/dim' import Vector from 'math/vector'; -import {EndPoint} from '../shapes/point' -import {Tool} from './tool' -import {DragTool} from "./drag"; -import {isInstanceOf} from "../actions/matchUtils"; -import {Segment} from "../shapes/segment"; -import {DEFAULT_SEARCH_BUFFER} from "../viewer2d"; -import {_negate, cross2d} from "math/vec"; -import {distance} from "math/distance"; +import { EndPoint } from '../shapes/point' +import { Tool } from './tool' +import { DragTool } from "./drag"; +import { isInstanceOf } from "../actions/matchUtils"; +import { Segment } from "../shapes/segment"; +import { DEFAULT_SEARCH_BUFFER } from "../viewer2d"; +import { _negate, cross2d } from "math/vec"; +import { distance } from "math/distance"; export class AddDimTool extends Tool { @@ -71,6 +71,19 @@ export class AddDimTool extends Tool { this.viewer.refresh(); } } + + keydown(e) { + if (e.keyCode == 27) { + //escape + if (this.dim != null) { + + const selection = this.viewer.selected.slice(); + this.viewer.removeAll(selection); + this.viewer.toolManager.releaseControl(); + this.viewer.refresh(); + } + } + } } export class AddFreeDimTool extends AddDimTool { @@ -230,7 +243,7 @@ export class AddAngleTool extends Tool { const [cx, cy] = isec; const v = [px - cx, py - cy]; - const insideSector = (v, v1, v2) => cross2d(v1, v) > 0 && cross2d(v2, v) < 0; + const insideSector = (v, v1, v2) => cross2d(v1, v) > 0 && cross2d(v2, v) < 0; if (insideSector(v, v1, v2)) { return [isec, [line1.a, line1.b, line2.a, line2.b]];