mirror of
https://github.com/xibyte/jsketcher
synced 2026-01-28 11:02:11 +01:00
Bug fix - don't allow dim tool to stay on the screen
This commit is contained in:
parent
aa249f95d2
commit
aba7cfb2b8
1 changed files with 22 additions and 9 deletions
|
|
@ -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]];
|
||||
|
|
|
|||
Loading…
Reference in a new issue