@design-core/core 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +14 -7
- package/.github/workflows/DesignCoreQA.yml +3 -1
- package/README.md +11 -4
- package/TODO.md +19 -0
- package/core/core/core.js +49 -42
- package/core/designCore.js +61 -2
- package/core/dimensions/alignedDimension.js +142 -0
- package/core/dimensions/angularDimension.js +550 -0
- package/core/dimensions/baseCircularDimension.js +244 -0
- package/core/dimensions/baseDimension.js +558 -0
- package/core/dimensions/baseLinearDimension.js +371 -0
- package/core/dimensions/diametricDimension.js +82 -0
- package/core/dimensions/dimension.js +298 -0
- package/core/dimensions/linearDimension.js +29 -0
- package/core/dimensions/radialDimension.js +78 -0
- package/core/dimensions/rotatedDimension.js +167 -0
- package/core/entities/arc.js +314 -60
- package/core/entities/arctext.js +642 -0
- package/core/entities/basePolyline.js +553 -94
- package/core/entities/circle.js +181 -54
- package/core/entities/entity.js +154 -74
- package/core/entities/hatch.js +807 -0
- package/core/entities/insert.js +200 -39
- package/core/entities/line.js +196 -134
- package/core/entities/lwpolyline.js +21 -44
- package/core/entities/point.js +194 -29
- package/core/entities/polyline.js +54 -7
- package/core/entities/rectangle.js +43 -13
- package/core/entities/solid.js +43 -6
- package/core/entities/text.js +324 -181
- package/core/lib/boundingBox.js +73 -13
- package/core/lib/canvas.js +256 -65
- package/core/lib/clipboard.js +198 -0
- package/core/lib/colour.js +144 -0
- package/core/lib/colours.js +367 -301
- package/core/lib/commandLine.js +16 -28
- package/core/lib/commandManager.js +115 -58
- package/core/lib/constants.js +23 -0
- package/core/lib/dxf/dxf.js +249 -34
- package/core/lib/dxf/dxfFile.js +23 -38
- package/core/lib/dxf/dxfIterator.js +17 -5
- package/core/lib/dxf/dxfRead.js +23 -7
- package/core/lib/dxf/dxfWrite.js +39 -129
- package/core/lib/dxf/handleManager.js +97 -0
- package/core/lib/dxf/sections/blocks.js +16 -2
- package/core/lib/dxf/sections/entities.js +17 -3
- package/core/lib/dxf/sections/header.js +10 -1
- package/core/lib/dxf/sections/objects.js +36 -0
- package/core/lib/dxf/sections/section.js +43 -5
- package/core/lib/dxf/sections/tables.js +17 -3
- package/core/lib/entityManager.js +178 -0
- package/core/lib/fileio.js +14 -4
- package/core/lib/headers.js +229 -0
- package/core/lib/input.js +46 -0
- package/core/lib/inputManager.js +199 -194
- package/core/lib/intersect.js +341 -468
- package/core/lib/logging.js +25 -1
- package/core/lib/matrix.js +6 -8
- package/core/lib/mouse.js +24 -79
- package/core/lib/patterns.js +690 -0
- package/core/lib/promptOptions.js +133 -0
- package/core/lib/scene.js +71 -174
- package/core/lib/selectionManager.js +74 -48
- package/core/lib/selectionWindow.js +24 -10
- package/core/lib/settings.js +18 -11
- package/core/lib/snapping.js +129 -21
- package/core/lib/stateManager.js +288 -0
- package/core/lib/strings.js +57 -5
- package/core/lib/utils.js +95 -11
- package/core/objects/dictionary.js +43 -0
- package/core/objects/dictionaryManager.js +80 -0
- package/core/properties/dimType.js +117 -0
- package/core/properties/flags.js +66 -0
- package/core/properties/property.js +26 -0
- package/core/properties/propertyManager.js +65 -19
- package/core/tables/appId.js +31 -0
- package/core/tables/appIdManager.js +44 -0
- package/core/tables/block.js +323 -0
- package/core/tables/blockManager.js +48 -0
- package/core/tables/blockRecord.js +29 -0
- package/core/tables/blockRecordManager.js +37 -0
- package/core/tables/dimStyle.js +627 -0
- package/core/tables/dimStyleManager.js +187 -0
- package/core/tables/endblk.js +28 -0
- package/core/tables/layer.js +219 -0
- package/core/tables/layerManager.js +47 -0
- package/core/tables/ltype.js +85 -0
- package/core/tables/ltypeManager.js +65 -0
- package/core/tables/style.js +145 -0
- package/core/tables/styleManager.js +55 -0
- package/core/tables/styleManagerBase.js +110 -0
- package/core/tables/tableManagerBase.js +354 -0
- package/core/tables/ucs.js +28 -0
- package/core/tables/ucsManager.js +44 -0
- package/core/tables/view.js +28 -0
- package/core/tables/viewManager.js +44 -0
- package/core/tables/vport.js +70 -0
- package/core/tables/vportManager.js +65 -0
- package/core/tools/chamfer.js +343 -0
- package/core/tools/chamferFilletBase.js +162 -0
- package/core/tools/copy.js +68 -40
- package/core/tools/copybase.js +65 -0
- package/core/tools/copyclip.js +59 -0
- package/core/tools/cornerEntity.js +138 -0
- package/core/tools/cutclip.js +72 -0
- package/core/tools/distance.js +37 -9
- package/core/tools/erase.js +43 -13
- package/core/tools/explode.js +117 -0
- package/core/tools/extend.js +71 -32
- package/core/tools/fillet.js +336 -0
- package/core/tools/identify.js +33 -6
- package/core/tools/matchProp.js +106 -0
- package/core/tools/mirror.js +141 -0
- package/core/tools/move.js +65 -32
- package/core/tools/offset.js +321 -0
- package/core/tools/pan.js +54 -0
- package/core/tools/pasteclip.js +93 -0
- package/core/tools/purge.js +90 -0
- package/core/tools/rotate.js +105 -70
- package/core/tools/scale.js +166 -0
- package/core/tools/tool.js +14 -4
- package/core/tools/trim.js +71 -32
- package/core/tools/zoom.js +152 -0
- package/package.json +3 -305
- package/test/dimensions/alignedDimension.test.js +211 -0
- package/test/dimensions/angularDimension.test.js +243 -0
- package/test/dimensions/baseDimension.test.js +239 -0
- package/test/dimensions/diametricDimension.test.js +203 -0
- package/test/dimensions/dimension.test.js +102 -0
- package/test/dimensions/radialDimension.test.js +203 -0
- package/test/dimensions/rotatedDimension.test.js +224 -0
- package/test/entities/arc.test.js +463 -41
- package/test/entities/arctext.test.js +329 -0
- package/test/entities/basePolyline.test.js +459 -10
- package/test/entities/circle.test.js +312 -7
- package/test/entities/entity.test.js +28 -9
- package/test/entities/hatch.test.js +606 -0
- package/test/entities/insert.test.js +90 -0
- package/test/entities/line.test.js +182 -6
- package/test/entities/point.test.js +375 -37
- package/test/entities/solid.test.js +156 -0
- package/test/entities/text.test.js +533 -7
- package/test/integration/exportIntegration.reference.dxf +1706 -0
- package/test/integration/exportIntegration.test.js +186 -0
- package/test/integration/importExportIntegration.test.js +126 -0
- package/test/integration/intersectionIntegration.test.js +880 -0
- package/test/integration/userInputIntegration.reference.dxf +1410 -0
- package/test/integration/userInputIntegration.test.js +269 -0
- package/test/lib/boundingBox.test.js +26 -2
- package/test/lib/canvas.test.js +613 -5
- package/test/lib/clipboard.test.js +70 -0
- package/test/lib/colour.test.js +114 -0
- package/test/lib/colours.test.js +63 -18
- package/test/lib/commandLine.test.js +159 -22
- package/test/lib/commandManager.test.js +4 -4
- package/test/lib/constants.test.js +9 -0
- package/test/lib/dxf/dxfFile.test.js +6 -2
- package/test/lib/dxf/dxfIterator.test.js +1 -1
- package/test/lib/dxf/dxfWrite.test.js +173 -0
- package/test/lib/dxf/handleManager.test.js +137 -0
- package/test/lib/dxf/sections/blocks.test.js +5 -5
- package/test/lib/dxf/sections/entities.test.js +4 -4
- package/test/lib/dxf/sections/header.test.js +18 -4
- package/test/lib/dxf/sections/objects.test.js +132 -0
- package/test/lib/dxf/sections/section.test.js +29 -29
- package/test/lib/dxf/sections/tables.test.js +3 -3
- package/test/lib/entityManager.test.js +163 -0
- package/test/lib/headers.test.js +233 -0
- package/test/lib/inputManager.test.js +1144 -5
- package/test/lib/intersect.test.js +454 -331
- package/test/lib/logging.test.js +1 -1
- package/test/lib/matrix.test.js +1 -1
- package/test/lib/mouse.test.js +327 -4
- package/test/lib/patterns.test.js +105 -0
- package/test/lib/promptOptions.test.js +179 -0
- package/test/lib/scene.test.js +16 -52
- package/test/lib/selectionManager.test.js +17 -5
- package/test/lib/settings.test.js +111 -5
- package/test/lib/snapping.test.js +142 -4
- package/test/lib/stateManager.test.js +155 -0
- package/test/lib/utils.test.js +81 -1
- package/test/objects/dictionary.test.js +81 -0
- package/test/objects/dictionaryManager.test.js +34 -0
- package/test/properties/dimType.test.js +62 -0
- package/test/properties/flags.test.js +164 -0
- package/test/properties/property.test.js +13 -0
- package/test/properties/propertyManager.test.js +10 -11
- package/test/tables/appId.test.js +46 -0
- package/test/tables/appIdManager.test.js +72 -0
- package/test/tables/block.test.js +157 -0
- package/test/tables/blockManager.test.js +52 -0
- package/test/tables/blockRecord.test.js +39 -0
- package/test/tables/blockRecordManager.test.js +60 -0
- package/test/tables/dimstyle.test.js +72 -0
- package/test/tables/endblk.test.js +30 -0
- package/test/tables/layer.test.js +95 -0
- package/test/tables/layerManager.test.js +172 -0
- package/test/{styles → tables}/ltype.test.js +7 -7
- package/test/{styles → tables}/ltypeManager.test.js +2 -2
- package/test/tables/style.test.js +44 -0
- package/test/tables/stylemanagerbase.test.js +220 -0
- package/test/tables/tableManagerBase.test.js +194 -0
- package/test/tables/ucs.test.js +37 -0
- package/test/tables/ucsManager.test.js +48 -0
- package/test/tables/view.test.js +37 -0
- package/test/tables/viewManager.test.js +48 -0
- package/test/tables/vport.test.js +117 -0
- package/test/tables/vportManager.test.js +54 -0
- package/test/test-helpers/test-helpers.js +66 -0
- package/test/tools/chamfer.test.js +970 -0
- package/test/tools/chamferFilletBase.test.js +446 -0
- package/test/tools/copy.test.js +22 -14
- package/test/tools/copybase.test.js +93 -0
- package/test/tools/copyclip.test.js +92 -0
- package/test/tools/cornerEntity.test.js +201 -0
- package/test/tools/cutclip.test.js +94 -0
- package/test/tools/distance.test.js +140 -18
- package/test/tools/erase.test.js +12 -12
- package/test/tools/explode.test.js +45 -0
- package/test/tools/extend.test.js +326 -44
- package/test/tools/fillet.test.js +831 -0
- package/test/tools/identify.test.js +115 -16
- package/test/tools/matchProp.test.js +84 -0
- package/test/tools/mirror.test.js +475 -0
- package/test/tools/move.test.js +75 -19
- package/test/tools/offset.test.js +748 -0
- package/test/tools/pan.test.js +72 -0
- package/test/tools/pasteclip.test.js +100 -0
- package/test/tools/purge.test.js +89 -0
- package/test/tools/rotate.test.js +89 -23
- package/test/tools/scale.test.js +529 -0
- package/test/tools/trim.test.js +419 -84
- package/test/tools/zoom.test.js +504 -0
- package/core/entities/alignedDimension.js +0 -279
- package/core/entities/angularDimension.js +0 -194
- package/core/entities/baseDimension.js +0 -227
- package/core/entities/block.js +0 -247
- package/core/entities/diametricDimension.js +0 -133
- package/core/entities/dimension.js +0 -202
- package/core/entities/radialDimension.js +0 -126
- package/core/styles/dimStyle.js +0 -719
- package/core/styles/dimStyleManager.js +0 -47
- package/core/styles/layer.js +0 -133
- package/core/styles/layerManager.js +0 -40
- package/core/styles/ltype.js +0 -86
- package/core/styles/ltypeManager.js +0 -50
- package/core/styles/style.js +0 -158
- package/core/styles/styleManager.js +0 -43
- package/core/styles/styleManagerBase.js +0 -299
- package/test/entities/block.test.js +0 -22
- package/test/styles/dimstyle.test.js +0 -19
- package/test/styles/layerManager.test.js +0 -150
- package/test/styles/style.test.js +0 -33
- package/test/styles/stylemanagerbase.test.js +0 -219
package/core/lib/logging.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/** Logging Class */
|
|
1
2
|
export class Logging {
|
|
2
3
|
static _instance;
|
|
3
|
-
|
|
4
|
+
/** Create Logger */
|
|
4
5
|
constructor() {
|
|
5
6
|
this.logLevel = ['OFF', 'ERROR', 'WARN', 'DEBUG', 'TRACE'];
|
|
6
7
|
this.level = 'DEBUG';
|
|
@@ -13,6 +14,7 @@ export class Logging {
|
|
|
13
14
|
return Logging._instance;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/** Get instance of logger */
|
|
16
18
|
static get instance() {
|
|
17
19
|
if (this._instance === undefined) {
|
|
18
20
|
this._instance = new this();
|
|
@@ -21,6 +23,10 @@ export class Logging {
|
|
|
21
23
|
return this._instance;
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Set logging level
|
|
28
|
+
* @param {number} level
|
|
29
|
+
*/
|
|
24
30
|
setLevel(level) {
|
|
25
31
|
if (this.logLevel.includes(level)) {
|
|
26
32
|
this.level = level;
|
|
@@ -29,10 +35,17 @@ export class Logging {
|
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Get the logging level
|
|
40
|
+
*/
|
|
32
41
|
get levelValue() {
|
|
33
42
|
return this.logLevel.indexOf(this.level);
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Print debug message
|
|
47
|
+
* @param {string} msg
|
|
48
|
+
*/
|
|
36
49
|
debug(msg) {
|
|
37
50
|
if (this.levelValue >= 3) {
|
|
38
51
|
console.log(`Debug: ${msg}`);
|
|
@@ -40,6 +53,10 @@ export class Logging {
|
|
|
40
53
|
}
|
|
41
54
|
}
|
|
42
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Print warning message
|
|
58
|
+
* @param {string} msg
|
|
59
|
+
*/
|
|
43
60
|
warn(msg) {
|
|
44
61
|
if (this.levelValue >= 2) {
|
|
45
62
|
console.log(`Warning: ${msg}`);
|
|
@@ -47,6 +64,10 @@ export class Logging {
|
|
|
47
64
|
}
|
|
48
65
|
}
|
|
49
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Print error message
|
|
69
|
+
* @param {string} msg
|
|
70
|
+
*/
|
|
50
71
|
error(msg) {
|
|
51
72
|
if (this.levelValue >= 1) {
|
|
52
73
|
console.log(`Error: ${msg}`);
|
|
@@ -54,6 +75,9 @@ export class Logging {
|
|
|
54
75
|
}
|
|
55
76
|
}
|
|
56
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Print trace
|
|
80
|
+
*/
|
|
57
81
|
trace() {
|
|
58
82
|
if (this.levelValue >= 4) {
|
|
59
83
|
console.trace();
|
package/core/lib/matrix.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {Point} from '../entities/point.js';
|
|
2
|
-
|
|
1
|
+
import { Point } from '../entities/point.js';
|
|
2
|
+
/** Matrix Class */
|
|
3
3
|
export class Matrix {
|
|
4
|
-
/**
|
|
5
|
-
* Matrix constructor
|
|
6
|
-
*/
|
|
4
|
+
/** Create Matrix */
|
|
7
5
|
constructor() {
|
|
8
6
|
this.a = 1; // x scale
|
|
9
7
|
this.b = 0; // x skew
|
|
@@ -15,7 +13,7 @@ export class Matrix {
|
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Returns the current scale
|
|
18
|
-
* @
|
|
16
|
+
* @return {number}
|
|
19
17
|
*/
|
|
20
18
|
getScale() {
|
|
21
19
|
// return the x scale
|
|
@@ -24,7 +22,7 @@ export class Matrix {
|
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* Returns inverted matrix
|
|
27
|
-
* @
|
|
25
|
+
* @return {Matrix}
|
|
28
26
|
*/
|
|
29
27
|
invert() {
|
|
30
28
|
const d = 1 / (this.a * this.d - this.b * this.c);
|
|
@@ -64,7 +62,7 @@ export class Matrix {
|
|
|
64
62
|
* Returns px and py transformed to matrix (scene) co-ordinates
|
|
65
63
|
* @param {number} px
|
|
66
64
|
* @param {number} py
|
|
67
|
-
* @
|
|
65
|
+
* @return {Point}
|
|
68
66
|
*/
|
|
69
67
|
transformPoint(px, py) {
|
|
70
68
|
const tpx = px * this.a + py * this.c + this.e;
|
package/core/lib/mouse.js
CHANGED
|
@@ -1,54 +1,23 @@
|
|
|
1
|
-
import {Point} from '../entities/point.js';
|
|
2
|
-
import {
|
|
3
|
-
import {DesignCore} from '../designCore.js';
|
|
1
|
+
import { Point } from '../entities/point.js';
|
|
2
|
+
import { DesignCore } from '../designCore.js';
|
|
4
3
|
|
|
4
|
+
/** Mouse Class */
|
|
5
5
|
export class Mouse {
|
|
6
|
-
/**
|
|
7
|
-
* Mouse Constructor
|
|
8
|
-
*/
|
|
6
|
+
/** Create Mouse */
|
|
9
7
|
constructor() {
|
|
10
8
|
this.x = 0;
|
|
11
9
|
this.y = 0;
|
|
12
10
|
this.buttonOneDown = false;
|
|
13
11
|
this.buttonTwoDown = false;
|
|
14
12
|
this.buttonThreeDown = false;
|
|
15
|
-
this.buttonOneDownScenePoint = new Point(); // store the location of the last scene click
|
|
16
13
|
this.mouseDownCanvasPoint = new Point();
|
|
17
14
|
this.lastClick = 0; // Timer for double click
|
|
18
15
|
this.lastButton = 0; // last button for double click check
|
|
19
16
|
}
|
|
20
17
|
|
|
21
|
-
/**
|
|
22
|
-
* Calculates the angle between the last mouse point and current position
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
inputAngle() {
|
|
26
|
-
const previousPoint = this.transformToScene(this.mouseDownCanvasPoint);
|
|
27
|
-
if (previousPoint) {
|
|
28
|
-
const angle = Utils.radians2degrees(previousPoint.angle(this.pointOnScene()));
|
|
29
|
-
return angle;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Calculates the distance between the last mouse point and current position
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
inputLength() {
|
|
40
|
-
if (this.mouseDownCanvasPoint) {
|
|
41
|
-
const lastScenePoint = this.transformToScene(this.mouseDownCanvasPoint);
|
|
42
|
-
const len = lastScenePoint.distance(this.pointOnScene());
|
|
43
|
-
return len;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
18
|
/**
|
|
50
19
|
* Returns the point on the design canvas
|
|
51
|
-
* @
|
|
20
|
+
* @return {Point}
|
|
52
21
|
*/
|
|
53
22
|
pointOnCanvas() {
|
|
54
23
|
return new Point(this.x, this.y);
|
|
@@ -56,7 +25,7 @@ export class Mouse {
|
|
|
56
25
|
|
|
57
26
|
/**
|
|
58
27
|
* Returns the point on the scene
|
|
59
|
-
* @
|
|
28
|
+
* @return {Point}
|
|
60
29
|
*/
|
|
61
30
|
pointOnScene() {
|
|
62
31
|
return this.transformToScene(this.pointOnCanvas());
|
|
@@ -64,47 +33,37 @@ export class Mouse {
|
|
|
64
33
|
|
|
65
34
|
/**
|
|
66
35
|
* Transforms the point location from canvas to scene space
|
|
67
|
-
* @param {
|
|
68
|
-
* @
|
|
36
|
+
* @param {Point} point
|
|
37
|
+
* @return {Point}
|
|
69
38
|
*/
|
|
70
39
|
transformToScene(point) {
|
|
71
|
-
const scenePoint = DesignCore.Canvas.matrix.invert().transformPoint(point.x, 0 - point.y +DesignCore.Canvas.height);
|
|
40
|
+
const scenePoint = DesignCore.Canvas.matrix.invert().transformPoint(point.x, 0 - point.y + DesignCore.Canvas.height);
|
|
72
41
|
return scenePoint;
|
|
73
42
|
}
|
|
74
43
|
|
|
75
44
|
/**
|
|
76
45
|
* Transforms the point location from scene to canvas space
|
|
77
|
-
* @param {
|
|
78
|
-
* @
|
|
46
|
+
* @param {Point} point
|
|
47
|
+
* @return {Point}
|
|
79
48
|
*/
|
|
80
49
|
transformToCanvas(point) {
|
|
81
50
|
const canvasPoint = DesignCore.Canvas.matrix.transformPoint(point.x, point.y);
|
|
82
|
-
canvasPoint.y = 0 - canvasPoint.y +DesignCore.Canvas.height;
|
|
51
|
+
canvasPoint.y = 0 - canvasPoint.y + DesignCore.Canvas.height;
|
|
83
52
|
return canvasPoint;
|
|
84
53
|
}
|
|
85
54
|
|
|
86
55
|
// TODO: This should be done outside of core in the ui.
|
|
87
56
|
/**
|
|
88
57
|
* Calculates the mouse position and angle string.
|
|
89
|
-
* @
|
|
58
|
+
* @return {string}
|
|
90
59
|
*/
|
|
91
60
|
positionString() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/*
|
|
97
|
-
// add the length to a previous when available
|
|
98
|
-
if (this.inputLength()) {
|
|
99
|
-
str = str + ', Len: ' + Math.round(this.inputLength());
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// add the angle from the previous point when available
|
|
103
|
-
if (this.inputAngle()) {
|
|
104
|
-
str = str + ', Ang: ' + Math.round(this.inputAngle());
|
|
105
|
-
}
|
|
106
|
-
*/
|
|
61
|
+
if (this.buttonOneDown || this.buttonTwoDown || this.buttonThreeDown) {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
107
64
|
|
|
65
|
+
const pt = this.pointOnScene();
|
|
66
|
+
const str = `X: ${pt.x.toFixed(1)} Y: ${pt.y.toFixed(1)}`;
|
|
108
67
|
return str;
|
|
109
68
|
}
|
|
110
69
|
|
|
@@ -122,20 +81,6 @@ export class Mouse {
|
|
|
122
81
|
// move the origin down to the bottom and invert the y position
|
|
123
82
|
this.y = -y + DesignCore.Canvas.height;
|
|
124
83
|
|
|
125
|
-
if (DesignCore.Settings.polar) {
|
|
126
|
-
// if polar is enabled - get the closest points
|
|
127
|
-
const polarSnap = DesignCore.Scene.inputManager.snapping.polarSnap(this.buttonOneDownScenePoint);
|
|
128
|
-
if (polarSnap) {
|
|
129
|
-
this.setPosFromScenePoint(polarSnap);
|
|
130
|
-
}
|
|
131
|
-
} else if (DesignCore.Settings.ortho) {
|
|
132
|
-
// if ortho is enabled - get the nearest ortho point
|
|
133
|
-
const orthoSnap = DesignCore.Scene.inputManager.snapping.orthoSnap(this.buttonOneDownScenePoint);
|
|
134
|
-
if (orthoSnap) {
|
|
135
|
-
this.setPosFromScenePoint(orthoSnap);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
84
|
DesignCore.Canvas.mouseMoved();
|
|
140
85
|
}
|
|
141
86
|
|
|
@@ -149,7 +94,6 @@ export class Mouse {
|
|
|
149
94
|
switch (button) {
|
|
150
95
|
case 0:
|
|
151
96
|
this.buttonOneDown = true;
|
|
152
|
-
this.buttonOneDownScenePoint = this.pointOnScene();
|
|
153
97
|
break;
|
|
154
98
|
case 1:
|
|
155
99
|
this.buttonTwoDown = true;
|
|
@@ -165,9 +109,9 @@ export class Mouse {
|
|
|
165
109
|
}
|
|
166
110
|
|
|
167
111
|
/**
|
|
168
|
-
* Timer function for
|
|
169
|
-
* @param {
|
|
170
|
-
* @
|
|
112
|
+
* Timer function for recognizing double clicks
|
|
113
|
+
* @param {number} button - 0 = left, 1 = wheel, 2 = right;
|
|
114
|
+
* @return {boolean}
|
|
171
115
|
*/
|
|
172
116
|
isDoubleClick(button) {
|
|
173
117
|
// measure time between clicks to check for double clicks in a generic way
|
|
@@ -176,9 +120,10 @@ export class Mouse {
|
|
|
176
120
|
const delta = thisClick - this.lastClick;
|
|
177
121
|
const isDoubleClick = delta < doubleClickThreshold;
|
|
178
122
|
this.lastClick = thisClick;
|
|
123
|
+
const lastButton = this.lastButton;
|
|
179
124
|
this.lastButton = button;
|
|
180
125
|
|
|
181
|
-
if (button ===
|
|
126
|
+
if (button === lastButton && isDoubleClick) {
|
|
182
127
|
this.doubleClick(button);
|
|
183
128
|
return true;
|
|
184
129
|
}
|
|
@@ -224,7 +169,7 @@ export class Mouse {
|
|
|
224
169
|
|
|
225
170
|
/**
|
|
226
171
|
* set mouse position from scene coordinates
|
|
227
|
-
* @param {
|
|
172
|
+
* @param {Point} point
|
|
228
173
|
*/
|
|
229
174
|
setPosFromScenePoint(point) {
|
|
230
175
|
const mousePos = this.transformToCanvas(point);
|