@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DXFFile } from '../../core/lib/dxf/dxfFile.js';
|
|
2
|
+
import { Dictionary } from '../../core/objects/dictionary.js';
|
|
3
|
+
|
|
4
|
+
test('Test Dictionary constructor defaults', () => {
|
|
5
|
+
const dict = new Dictionary();
|
|
6
|
+
expect(dict.name).toBe('');
|
|
7
|
+
expect(dict.duplicateRecordCloning).toBe(1);
|
|
8
|
+
expect(dict.entries).toEqual([]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('Test Dictionary constructor with name property', () => {
|
|
12
|
+
const dict = new Dictionary({ name: 'ACAD_GROUP' });
|
|
13
|
+
expect(dict.name).toBe('ACAD_GROUP');
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('Test Dictionary constructor with DXF group code', () => {
|
|
17
|
+
const dict = new Dictionary({ 3: 'ACAD_GROUP' });
|
|
18
|
+
expect(dict.name).toBe('ACAD_GROUP');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Test Dictionary constructor with entries', () => {
|
|
22
|
+
const dict = new Dictionary({
|
|
23
|
+
entries: [{ name: 'ACAD_GROUP', handle: 'D' }],
|
|
24
|
+
});
|
|
25
|
+
expect(dict.entries.length).toBe(1);
|
|
26
|
+
expect(dict.entries[0].name).toBe('ACAD_GROUP');
|
|
27
|
+
expect(dict.entries[0].handle).toBe('D');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Test Dictionary constructor with duplicateRecordCloning', () => {
|
|
31
|
+
const dict = new Dictionary({ duplicateRecordCloning: 0 });
|
|
32
|
+
expect(dict.duplicateRecordCloning).toBe(0);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('Test Dictionary constructor with DXF group code 281', () => {
|
|
36
|
+
const dict = new Dictionary({ 281: 0 });
|
|
37
|
+
expect(dict.duplicateRecordCloning).toBe(0);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('Test Dictionary.dxf with no entries', () => {
|
|
41
|
+
const dict = new Dictionary({ name: 'ACAD_GROUP', handle: '1A' });
|
|
42
|
+
const file = new DXFFile();
|
|
43
|
+
dict.dxf(file);
|
|
44
|
+
|
|
45
|
+
const dxfString = `0
|
|
46
|
+
DICTIONARY
|
|
47
|
+
5
|
|
48
|
+
1A
|
|
49
|
+
100
|
|
50
|
+
AcDbDictionary
|
|
51
|
+
281
|
|
52
|
+
1
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
expect(file.contents).toEqual(dxfString);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('Test Dictionary.dxf with entries', () => {
|
|
59
|
+
const dict = new Dictionary({
|
|
60
|
+
handle: '1B',
|
|
61
|
+
entries: [{ name: 'ACAD_GROUP', handle: 'D' }],
|
|
62
|
+
});
|
|
63
|
+
const file = new DXFFile();
|
|
64
|
+
dict.dxf(file);
|
|
65
|
+
|
|
66
|
+
const dxfString = `0
|
|
67
|
+
DICTIONARY
|
|
68
|
+
5
|
|
69
|
+
1B
|
|
70
|
+
100
|
|
71
|
+
AcDbDictionary
|
|
72
|
+
281
|
|
73
|
+
1
|
|
74
|
+
3
|
|
75
|
+
ACAD_GROUP
|
|
76
|
+
350
|
|
77
|
+
D
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
expect(file.contents).toEqual(dxfString);
|
|
81
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Core } from '../../core/core/core.js';
|
|
2
|
+
import { DXFFile } from '../../core/lib/dxf/dxfFile.js';
|
|
3
|
+
|
|
4
|
+
const core = new Core();
|
|
5
|
+
const dictionaryManager = core.dictionaryManager;
|
|
6
|
+
|
|
7
|
+
test('Test DictionaryManager.dxf', () => {
|
|
8
|
+
const file = new DXFFile();
|
|
9
|
+
dictionaryManager.dxf(file);
|
|
10
|
+
|
|
11
|
+
const dxfString = `0
|
|
12
|
+
DICTIONARY
|
|
13
|
+
5
|
|
14
|
+
27
|
|
15
|
+
100
|
|
16
|
+
AcDbDictionary
|
|
17
|
+
281
|
|
18
|
+
1
|
|
19
|
+
3
|
|
20
|
+
ACAD_GROUP
|
|
21
|
+
350
|
|
22
|
+
26
|
|
23
|
+
0
|
|
24
|
+
DICTIONARY
|
|
25
|
+
5
|
|
26
|
+
26
|
|
27
|
+
100
|
|
28
|
+
AcDbDictionary
|
|
29
|
+
281
|
|
30
|
+
1
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
expect(file.contents).toEqual(dxfString);
|
|
34
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DimType } from '../../core/properties/dimType';
|
|
2
|
+
|
|
3
|
+
test('DimType - constructor sets default and custom dimType', () => {
|
|
4
|
+
expect(new DimType().dimType).toBe(0);
|
|
5
|
+
expect(new DimType(3).dimType).toBe(3);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test('DimType - isValidDimensionType returns true for valid, false for invalid', () => {
|
|
9
|
+
expect(DimType.isValidDimensionType(0)).toBe(true);
|
|
10
|
+
expect(DimType.isValidDimensionType(6)).toBe(true);
|
|
11
|
+
expect(DimType.isValidDimensionType(32)).toBe(true); // block ref
|
|
12
|
+
expect(DimType.isValidDimensionType(64)).toBe(true);
|
|
13
|
+
expect(DimType.isValidDimensionType(70)).toBe(true);
|
|
14
|
+
expect(DimType.isValidDimensionType(99)).toBe(true); // 32 + 64 + 3
|
|
15
|
+
expect(DimType.isValidDimensionType(128)).toBe(true);
|
|
16
|
+
|
|
17
|
+
expect(DimType.isValidDimensionType(-1)).toBe(false);
|
|
18
|
+
expect(DimType.isValidDimensionType(9)).toBe(false);
|
|
19
|
+
expect(DimType.isValidDimensionType(999)).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('DimType - getBaseType returns correct base type', () => {
|
|
23
|
+
expect(DimType.getBaseType(0)).toBe(0);
|
|
24
|
+
expect(DimType.getBaseType(32)).toBe(0);
|
|
25
|
+
expect(DimType.getBaseType(34)).toBe(2);
|
|
26
|
+
expect(DimType.getBaseType(36)).toBe(4);
|
|
27
|
+
expect(DimType.getBaseType(39)).toBe(7); // 7 is invalid but still returned as base type
|
|
28
|
+
expect(DimType.getBaseType(70)).toBe(6);
|
|
29
|
+
expect(DimType.getBaseType(64)).toBe(0);
|
|
30
|
+
expect(DimType.getBaseType(65)).toBe(1);
|
|
31
|
+
expect(DimType.getBaseType(128)).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('DimType - getDimType returns correct dimType for various values', () => {
|
|
35
|
+
// getDimType should return the input value as-is for valid values
|
|
36
|
+
expect(new DimType(0).getDimType()).toBe(0);
|
|
37
|
+
expect(new DimType(3).getDimType()).toBe(3);
|
|
38
|
+
expect(new DimType(32).getDimType()).toBe(32);
|
|
39
|
+
expect(new DimType(70).getDimType()).toBe(70);
|
|
40
|
+
expect(new DimType(128).getDimType()).toBe(128);
|
|
41
|
+
expect(new DimType(99).getDimType()).toBe(99);
|
|
42
|
+
|
|
43
|
+
// For invalid or undefined input, should return default (likely 0)
|
|
44
|
+
expect(new DimType(undefined).getDimType()).toBe(0);
|
|
45
|
+
expect(new DimType(null).getDimType()).toBe(0);
|
|
46
|
+
expect(new DimType(NaN).getDimType()).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('DimType - hasBlockReference detects block reference bit', () => {
|
|
50
|
+
expect(new DimType(32).hasBlockReference()).toBe(true);
|
|
51
|
+
expect(new DimType(38).hasBlockReference()).toBe(true); // 6 + 32
|
|
52
|
+
expect(new DimType(2).hasBlockReference()).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('DimType - hasUserPositionedText detects user positioned text bit', () => {
|
|
56
|
+
expect(new DimType(128).hasUserPositionedText()).toBe(true);
|
|
57
|
+
expect(new DimType(129).hasUserPositionedText()).toBe(true);
|
|
58
|
+
expect(new DimType(134).hasUserPositionedText()).toBe(true);
|
|
59
|
+
expect(new DimType(2).hasUserPositionedText()).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
|
|
2
|
+
import { Flags } from '../../core/properties/flags';
|
|
3
|
+
|
|
4
|
+
test('Test flags set/get FlagValue', () => {
|
|
5
|
+
const flags = new Flags();
|
|
6
|
+
flags.setFlagValue(10);
|
|
7
|
+
expect(flags.getFlagValue()).toBe(10);
|
|
8
|
+
flags.setFlagValue(5);
|
|
9
|
+
expect(flags.getFlagValue()).toBe(5);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('Test flags.hasFlag', () => {
|
|
13
|
+
const flags = new Flags();
|
|
14
|
+
expect(flags.hasFlag(1)).toBe(false);
|
|
15
|
+
|
|
16
|
+
// set flag value to 17
|
|
17
|
+
flags.addValue(17);
|
|
18
|
+
/* bit masked value
|
|
19
|
+
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|
|
20
|
+
0 0 0 1 0 0 0 1
|
|
21
|
+
*/
|
|
22
|
+
// 1 should exist
|
|
23
|
+
expect(flags.hasFlag(1)).toBe(true);
|
|
24
|
+
// 2 shouldn't exist
|
|
25
|
+
expect(flags.hasFlag(2)).toBe(false);
|
|
26
|
+
// 3 shouldn't exist
|
|
27
|
+
expect(flags.hasFlag(3)).toBe(false);
|
|
28
|
+
// 4 shouldn't exist
|
|
29
|
+
expect(flags.hasFlag(4)).toBe(false);
|
|
30
|
+
// 5 shouldn't exist
|
|
31
|
+
expect(flags.hasFlag(5)).toBe(false);
|
|
32
|
+
// 6 shouldn't exist
|
|
33
|
+
expect(flags.hasFlag(6)).toBe(false);
|
|
34
|
+
// 8 shouldn't exist
|
|
35
|
+
expect(flags.hasFlag(8)).toBe(false);
|
|
36
|
+
// 16 shouldn't exist
|
|
37
|
+
expect(flags.hasFlag(16)).toBe(true);
|
|
38
|
+
// 32 shouldn't exist
|
|
39
|
+
expect(flags.hasFlag(32)).toBe(false);
|
|
40
|
+
// 64 shouldn't exist
|
|
41
|
+
expect(flags.hasFlag(64)).toBe(false);
|
|
42
|
+
// 128 shouldn't exist
|
|
43
|
+
expect(flags.hasFlag(128)).toBe(false);
|
|
44
|
+
|
|
45
|
+
// add flag value 3; total 19
|
|
46
|
+
flags.addValue(3);
|
|
47
|
+
/* bit masked value
|
|
48
|
+
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|
|
49
|
+
0 0 0 1 0 0 1 1
|
|
50
|
+
*/
|
|
51
|
+
// 1 should exist
|
|
52
|
+
expect(flags.hasFlag(1)).toBe(true);
|
|
53
|
+
// 2 shouldn't exist
|
|
54
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
55
|
+
// 3 shouldn't exist
|
|
56
|
+
expect(flags.hasFlag(3)).toBe(true);
|
|
57
|
+
// 4 shouldn't exist
|
|
58
|
+
expect(flags.hasFlag(4)).toBe(false);
|
|
59
|
+
// 5 shouldn't exist
|
|
60
|
+
expect(flags.hasFlag(5)).toBe(false);
|
|
61
|
+
// 6 shouldn't exist
|
|
62
|
+
expect(flags.hasFlag(6)).toBe(false);
|
|
63
|
+
// 8 shouldn't exist
|
|
64
|
+
expect(flags.hasFlag(8)).toBe(false);
|
|
65
|
+
// 16 shouldn't exist
|
|
66
|
+
expect(flags.hasFlag(16)).toBe(true);
|
|
67
|
+
// 32 shouldn't exist
|
|
68
|
+
expect(flags.hasFlag(32)).toBe(false);
|
|
69
|
+
// 64 shouldn't exist
|
|
70
|
+
expect(flags.hasFlag(64)).toBe(false);
|
|
71
|
+
// 128 shouldn't exist
|
|
72
|
+
expect(flags.hasFlag(128)).toBe(false);
|
|
73
|
+
|
|
74
|
+
// try and add 3 again
|
|
75
|
+
// add flag value 3 again; total still 19
|
|
76
|
+
flags.addValue(3);
|
|
77
|
+
/* bit masked value
|
|
78
|
+
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|
|
79
|
+
0 0 0 1 0 0 1 1
|
|
80
|
+
*/
|
|
81
|
+
// 1 should exist
|
|
82
|
+
expect(flags.hasFlag(1)).toBe(true);
|
|
83
|
+
// 2 shouldn't exist
|
|
84
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
85
|
+
// 3 shouldn't exist
|
|
86
|
+
expect(flags.hasFlag(3)).toBe(true);
|
|
87
|
+
// 4 shouldn't exist
|
|
88
|
+
expect(flags.hasFlag(4)).toBe(false);
|
|
89
|
+
// 5 shouldn't exist
|
|
90
|
+
expect(flags.hasFlag(5)).toBe(false);
|
|
91
|
+
// 6 shouldn't exist
|
|
92
|
+
expect(flags.hasFlag(6)).toBe(false);
|
|
93
|
+
// 8 shouldn't exist
|
|
94
|
+
expect(flags.hasFlag(8)).toBe(false);
|
|
95
|
+
// 16 shouldn't exist
|
|
96
|
+
expect(flags.hasFlag(16)).toBe(true);
|
|
97
|
+
// 32 shouldn't exist
|
|
98
|
+
expect(flags.hasFlag(32)).toBe(false);
|
|
99
|
+
// 64 shouldn't exist
|
|
100
|
+
expect(flags.hasFlag(64)).toBe(false);
|
|
101
|
+
// 128 shouldn't exist
|
|
102
|
+
expect(flags.hasFlag(128)).toBe(false);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('Test flags.addValue', () => {
|
|
106
|
+
const flags = new Flags();
|
|
107
|
+
// 2 shouldn't exist
|
|
108
|
+
expect(flags.hasFlag(2)).toBe(false);
|
|
109
|
+
// add flag value 2
|
|
110
|
+
flags.addValue(2);
|
|
111
|
+
// 2 should exist
|
|
112
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
113
|
+
// add flag value 3
|
|
114
|
+
flags.addValue(3);
|
|
115
|
+
// 3 should exist
|
|
116
|
+
expect(flags.hasFlag(1)).toBe(true);
|
|
117
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
118
|
+
expect(flags.hasFlag(3)).toBe(true);
|
|
119
|
+
expect(flags.hasFlag(4)).toBe(false);
|
|
120
|
+
expect(flags.getFlagValue()).toBe(3);
|
|
121
|
+
|
|
122
|
+
// add flag value 3 again
|
|
123
|
+
flags.addValue(3);
|
|
124
|
+
// 3 should still exist
|
|
125
|
+
expect(flags.hasFlag(3)).toBe(true);
|
|
126
|
+
// flags value should still be 3
|
|
127
|
+
expect(flags.getFlagValue()).toBe(3);
|
|
128
|
+
|
|
129
|
+
// set flag value to 0
|
|
130
|
+
flags.setFlagValue(2);
|
|
131
|
+
// add flag value 2
|
|
132
|
+
flags.addValue(2);
|
|
133
|
+
// 2 should exist
|
|
134
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
135
|
+
// flag value should be 2
|
|
136
|
+
expect(flags.getFlagValue()).toBe(2);
|
|
137
|
+
|
|
138
|
+
// repeat add to check for unwanted behaviour
|
|
139
|
+
// add flag value 2 a second time
|
|
140
|
+
flags.addValue(2);
|
|
141
|
+
// 2 should exist
|
|
142
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
143
|
+
// flag value should still be 2
|
|
144
|
+
expect(flags.getFlagValue()).toBe(2);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('Test flags.removeValue', () => {
|
|
148
|
+
const flags = new Flags();
|
|
149
|
+
// 2 shouldn't exist
|
|
150
|
+
expect(flags.hasFlag(2)).toBe(false);
|
|
151
|
+
// add flag value 2
|
|
152
|
+
flags.addValue(2);
|
|
153
|
+
// 2 should exist
|
|
154
|
+
expect(flags.hasFlag(2)).toBe(true);
|
|
155
|
+
// remove flag value 2
|
|
156
|
+
flags.removeValue(2);
|
|
157
|
+
// 2 shouldn't exist again
|
|
158
|
+
expect(flags.hasFlag(2)).toBe(false);
|
|
159
|
+
|
|
160
|
+
// repeat remove to check for unwanted behaviour
|
|
161
|
+
flags.removeValue(2);
|
|
162
|
+
// 2 shouldn't exist again
|
|
163
|
+
expect(flags.hasFlag(2)).toBe(false);
|
|
164
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Property } from '../../core/properties/property';
|
|
2
|
+
import { Flags } from '../../core/properties/flags';
|
|
3
|
+
|
|
4
|
+
test('Test property.loadValue', () => {
|
|
5
|
+
expect(Property.loadValue([], 3)).toBe(3);
|
|
6
|
+
expect(Property.loadValue([1, 2], 3)).toBe(1);
|
|
7
|
+
expect(Property.loadValue([undefined, 2], 3)).toBe(2);
|
|
8
|
+
expect(Property.loadValue([undefined], 3)).toBe(3);
|
|
9
|
+
|
|
10
|
+
const flags = new Flags();
|
|
11
|
+
flags.setFlagValue(4);
|
|
12
|
+
expect(Property.loadValue([flags], 3)).toBe(4);
|
|
13
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import {Core} from '../../core/core/core.js';
|
|
3
|
-
import {DesignCore} from '../../core/designCore.js';
|
|
4
|
-
import {Point} from '../../core/entities/point.js';
|
|
2
|
+
import { Core } from '../../core/core/core.js';
|
|
3
|
+
import { DesignCore } from '../../core/designCore.js';
|
|
4
|
+
import { Point } from '../../core/entities/point.js';
|
|
5
5
|
|
|
6
6
|
const core = new Core();
|
|
7
7
|
const propertiesManager = core.propertyManager;
|
|
@@ -11,14 +11,14 @@ const point2 = new Point(0, 100);
|
|
|
11
11
|
|
|
12
12
|
const data = {
|
|
13
13
|
points: [point1, point2],
|
|
14
|
-
colour:
|
|
14
|
+
colour: { r: 100, g: 100, b: 100 },
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
DesignCore.Scene.addItem('Line', data);
|
|
18
18
|
DesignCore.Scene.addItem('Circle', data);
|
|
19
19
|
DesignCore.Scene.addItem('Text', data);
|
|
20
20
|
// Add Arc with a different Colour
|
|
21
|
-
DesignCore.Scene.addItem('Arc', {points: [point1, point2], colour:
|
|
21
|
+
DesignCore.Scene.addItem('Arc', { points: [point1, point2], colour: { r: 130, g: 130, b: 130 } });
|
|
22
22
|
|
|
23
23
|
test('Test propertyManager.getItemTypes', () => {
|
|
24
24
|
// Add an item to the selectionSet
|
|
@@ -47,13 +47,13 @@ test('Test propertyManager.setItemProperties', () => {
|
|
|
47
47
|
const string = 'test text';
|
|
48
48
|
propertiesManager.setItemProperties('string', string);
|
|
49
49
|
|
|
50
|
-
let text = DesignCore.Scene.
|
|
50
|
+
let text = DesignCore.Scene.entities.get(2);
|
|
51
51
|
expect(text.type).toBe('Text');
|
|
52
52
|
expect(text.string).toBe(string);
|
|
53
53
|
|
|
54
54
|
// try and set a non-existent property
|
|
55
55
|
propertiesManager.setItemProperties('faux-prop', string);
|
|
56
|
-
text = DesignCore.Scene.
|
|
56
|
+
text = DesignCore.Scene.entities.get(2);
|
|
57
57
|
expect(text['faux-prop']).toBeUndefined();
|
|
58
58
|
|
|
59
59
|
// clear the selection set
|
|
@@ -61,10 +61,10 @@ test('Test propertyManager.setItemProperties', () => {
|
|
|
61
61
|
// Select the circle element
|
|
62
62
|
DesignCore.Scene.selectionManager.selectionSet.selectionSet.push(1);
|
|
63
63
|
// get the current radius
|
|
64
|
-
const radius = DesignCore.Scene.
|
|
64
|
+
const radius = DesignCore.Scene.entities.get(1).radius;
|
|
65
65
|
// try and set an incorrect value
|
|
66
66
|
propertiesManager.setItemProperties('radius', string);
|
|
67
|
-
const circle = DesignCore.Scene.
|
|
67
|
+
const circle = DesignCore.Scene.entities.get(1);
|
|
68
68
|
expect(circle.radius).toBe(radius);
|
|
69
69
|
});
|
|
70
70
|
|
|
@@ -102,8 +102,7 @@ test('Test propertyManager.getItemPropertyValue', () => {
|
|
|
102
102
|
DesignCore.Scene.selectionManager.selectionSet.selectionSet.push(0);
|
|
103
103
|
// get the line colour
|
|
104
104
|
propertyValues = propertiesManager.getItemPropertyValue('Line', 'colour');
|
|
105
|
-
expect(propertyValues
|
|
106
|
-
expect(propertyValues).toBe(data.colour);
|
|
105
|
+
expect(propertyValues).toEqual(data.colour);
|
|
107
106
|
|
|
108
107
|
// get circle props with a line selected - should be undefined
|
|
109
108
|
propertyValues = propertiesManager.getItemPropertyValue('Circle', 'colour');
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DXFFile } from '../../core/lib/dxf/dxfFile.js';
|
|
2
|
+
import { AppID } from '../../core/tables/appId.js';
|
|
3
|
+
|
|
4
|
+
test('Test AppID constructor defaults', () => {
|
|
5
|
+
const appId = new AppID();
|
|
6
|
+
expect(appId.name).toBe('');
|
|
7
|
+
expect(appId.flags).toBe(0);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('Test AppID constructor with name property', () => {
|
|
11
|
+
const appId = new AppID({ name: 'ACAD' });
|
|
12
|
+
expect(appId.name).toBe('ACAD');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Test AppID constructor with DXF group codes', () => {
|
|
16
|
+
const appId = new AppID({ 2: 'ACAD', 70: 0 });
|
|
17
|
+
expect(appId.name).toBe('ACAD');
|
|
18
|
+
expect(appId.flags).toBe(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Test AppID constructor with flags', () => {
|
|
22
|
+
const appId = new AppID({ name: 'TestApp', flags: 1 });
|
|
23
|
+
expect(appId.flags).toBe(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('Test AppID.dxf', () => {
|
|
27
|
+
const appId = new AppID({ handle: 'A', name: 'ACAD' });
|
|
28
|
+
const file = new DXFFile();
|
|
29
|
+
appId.dxf(file);
|
|
30
|
+
|
|
31
|
+
const dxfString = `0
|
|
32
|
+
APPID
|
|
33
|
+
5
|
|
34
|
+
A
|
|
35
|
+
100
|
|
36
|
+
AcDbSymbolTableRecord
|
|
37
|
+
100
|
|
38
|
+
AcDbRegAppTableRecord
|
|
39
|
+
2
|
|
40
|
+
ACAD
|
|
41
|
+
70
|
|
42
|
+
0
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
expect(file.contents).toEqual(dxfString);
|
|
46
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Core } from '../../core/core/core.js';
|
|
2
|
+
import { DXFFile } from '../../core/lib/dxf/dxfFile.js';
|
|
3
|
+
|
|
4
|
+
const core = new Core();
|
|
5
|
+
const appIdManager = core.appIdManager;
|
|
6
|
+
|
|
7
|
+
test('Test AppIDManager.getItems', () => {
|
|
8
|
+
const items = appIdManager.getItems();
|
|
9
|
+
expect(items).toHaveLength(1);
|
|
10
|
+
expect(items[0]).toHaveProperty('name', 'ACAD');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('Test AppIDManager.itemCount', () => {
|
|
14
|
+
expect(appIdManager.itemCount()).toBe(1);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('Test AppIDManager.addItem', () => {
|
|
18
|
+
const count = appIdManager.itemCount();
|
|
19
|
+
appIdManager.addItem({ name: 'TestApp' });
|
|
20
|
+
expect(appIdManager.itemCount()).toBe(count + 1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Test AppIDManager.deleteItem indelible', () => {
|
|
24
|
+
const count = appIdManager.itemCount();
|
|
25
|
+
const index = appIdManager.getItemIndex('ACAD');
|
|
26
|
+
appIdManager.deleteItem(index);
|
|
27
|
+
// ACAD is indelible and cannot be deleted
|
|
28
|
+
expect(appIdManager.itemCount()).toBe(count);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('Test AppIDManager.deleteItem', () => {
|
|
32
|
+
const count = appIdManager.itemCount();
|
|
33
|
+
const index = appIdManager.getItemIndex('TestApp');
|
|
34
|
+
appIdManager.deleteItem(index);
|
|
35
|
+
expect(appIdManager.itemCount()).toBe(count - 1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Test AppIDManager.itemExists', () => {
|
|
39
|
+
expect(appIdManager.itemExists('ACAD')).toBe(true);
|
|
40
|
+
expect(appIdManager.itemExists('NonExistent')).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('Test AppIDManager.dxf', () => {
|
|
44
|
+
const file = new DXFFile();
|
|
45
|
+
appIdManager.dxf(file);
|
|
46
|
+
|
|
47
|
+
const dxfString = `0
|
|
48
|
+
TABLE
|
|
49
|
+
2
|
|
50
|
+
APPID
|
|
51
|
+
5
|
|
52
|
+
23
|
|
53
|
+
100
|
|
54
|
+
AcDbSymbolTable
|
|
55
|
+
0
|
|
56
|
+
APPID
|
|
57
|
+
5
|
|
58
|
+
24
|
|
59
|
+
100
|
|
60
|
+
AcDbSymbolTableRecord
|
|
61
|
+
100
|
|
62
|
+
AcDbRegAppTableRecord
|
|
63
|
+
2
|
|
64
|
+
ACAD
|
|
65
|
+
70
|
|
66
|
+
0
|
|
67
|
+
0
|
|
68
|
+
ENDTAB
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
expect(file.contents).toEqual(dxfString);
|
|
72
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Core } from '../../core/core/core.js';
|
|
2
|
+
import { Block } from '../../core/tables/block.js';
|
|
3
|
+
import { Line } from '../../core/entities/line.js';
|
|
4
|
+
import { Point } from '../../core/entities/point.js';
|
|
5
|
+
|
|
6
|
+
import { File } from '../test-helpers/test-helpers.js';
|
|
7
|
+
import { Flags } from '../../core/properties/flags.js';
|
|
8
|
+
|
|
9
|
+
new Core();
|
|
10
|
+
|
|
11
|
+
test('Test Block', () => {
|
|
12
|
+
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
13
|
+
const flags = new Flags();
|
|
14
|
+
flags.addValue(1);
|
|
15
|
+
const block = new Block({ items: [line], flags: flags });
|
|
16
|
+
|
|
17
|
+
expect(block.items.length).toBe(1);
|
|
18
|
+
expect(block.flags.getFlagValue()).toBe(1);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Test Block.clearItems', () => {
|
|
22
|
+
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
23
|
+
const block = new Block({ items: [line] });
|
|
24
|
+
expect(block.items.length).toBe(1);
|
|
25
|
+
|
|
26
|
+
block.clearItems();
|
|
27
|
+
expect(block.items.length).toBe(0);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('Test Block.snaps', () => {
|
|
31
|
+
const block = new Block();
|
|
32
|
+
expect(block.snaps()).toBeInstanceOf(Array);
|
|
33
|
+
expect(block.snaps()).toHaveLength(0);
|
|
34
|
+
|
|
35
|
+
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
36
|
+
block.addItem(line);
|
|
37
|
+
expect(block.snaps()).toBeInstanceOf(Array);
|
|
38
|
+
expect(block.snaps()).not.toHaveLength(0);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('Test Block', () => {
|
|
42
|
+
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
43
|
+
const flags = new Flags();
|
|
44
|
+
flags.addValue(1);
|
|
45
|
+
const block = new Block({ items: [line], flags: flags });
|
|
46
|
+
|
|
47
|
+
expect(block.items.length).toBe(1);
|
|
48
|
+
expect(block.flags.getFlagValue()).toBe(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('Test Block.closestPoint', () => {
|
|
52
|
+
const block = new Block();
|
|
53
|
+
const point = new Point();
|
|
54
|
+
|
|
55
|
+
expect(block.closestPoint(point)).toBeInstanceOf(Array);
|
|
56
|
+
expect(block.closestPoint(point)).toHaveLength(2);
|
|
57
|
+
expect(block.closestPoint(point)[0]).toBeInstanceOf(Point);
|
|
58
|
+
expect(block.closestPoint(point)[0].x).toBe(0);
|
|
59
|
+
expect(block.closestPoint(point)[0].y).toBe(0);
|
|
60
|
+
expect(block.closestPoint(point)[1]).toBe(Infinity);
|
|
61
|
+
|
|
62
|
+
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
63
|
+
block.addItem(line);
|
|
64
|
+
expect(block.closestPoint(point)).toBeInstanceOf(Array);
|
|
65
|
+
expect(block.closestPoint(point)).toHaveLength(2);
|
|
66
|
+
expect(block.closestPoint(point)[0]).toBeInstanceOf(Point);
|
|
67
|
+
expect(block.closestPoint(point)[0].x).not.toBe(0);
|
|
68
|
+
expect(block.closestPoint(point)[0].y).not.toBe(0);
|
|
69
|
+
expect(block.closestPoint(point)[1]).not.toBe(Infinity);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('Test Block.dxf', () => {
|
|
73
|
+
const block = new Block({ handle: '1', endblkHandle: '1' });
|
|
74
|
+
const line = new Line({ handle: '1', points: [new Point(101, 102), new Point(201, 202)] });
|
|
75
|
+
block.addItem(line);
|
|
76
|
+
|
|
77
|
+
const file = new File();
|
|
78
|
+
block.dxf(file);
|
|
79
|
+
// console.log(file.contents);
|
|
80
|
+
|
|
81
|
+
const dxfString = `0
|
|
82
|
+
BLOCK
|
|
83
|
+
5
|
|
84
|
+
1
|
|
85
|
+
100
|
|
86
|
+
AcDbEntity
|
|
87
|
+
8
|
|
88
|
+
0
|
|
89
|
+
100
|
|
90
|
+
AcDbBlockBegin
|
|
91
|
+
2
|
|
92
|
+
|
|
93
|
+
70
|
|
94
|
+
0
|
|
95
|
+
10
|
|
96
|
+
0
|
|
97
|
+
20
|
|
98
|
+
0
|
|
99
|
+
30
|
|
100
|
+
0
|
|
101
|
+
3
|
|
102
|
+
|
|
103
|
+
1
|
|
104
|
+
|
|
105
|
+
0
|
|
106
|
+
LINE
|
|
107
|
+
5
|
|
108
|
+
1
|
|
109
|
+
100
|
|
110
|
+
AcDbEntity
|
|
111
|
+
100
|
|
112
|
+
AcDbLine
|
|
113
|
+
8
|
|
114
|
+
0
|
|
115
|
+
6
|
|
116
|
+
ByLayer
|
|
117
|
+
10
|
|
118
|
+
101
|
|
119
|
+
20
|
|
120
|
+
102
|
|
121
|
+
30
|
|
122
|
+
0.0
|
|
123
|
+
11
|
|
124
|
+
201
|
|
125
|
+
21
|
|
126
|
+
202
|
|
127
|
+
31
|
|
128
|
+
0.0
|
|
129
|
+
39
|
|
130
|
+
2
|
|
131
|
+
0
|
|
132
|
+
ENDBLK
|
|
133
|
+
5
|
|
134
|
+
1
|
|
135
|
+
100
|
|
136
|
+
AcDbEntity
|
|
137
|
+
100
|
|
138
|
+
AcDbBlockEnd
|
|
139
|
+
`;
|
|
140
|
+
|
|
141
|
+
expect(file.contents).toEqual(dxfString);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('Test Block.touched', () => {
|
|
145
|
+
const block = new Block();
|
|
146
|
+
|
|
147
|
+
// Selection {min, max}
|
|
148
|
+
const selectionExtremesTrue = { min: new Point(110, 90), max: new Point(190, 210) };
|
|
149
|
+
const selectionExtremesFalse = { min: new Point(250, 250), max: new Point(400, 400) };
|
|
150
|
+
|
|
151
|
+
expect(block.touched(selectionExtremesTrue)).toBe(false);
|
|
152
|
+
|
|
153
|
+
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
154
|
+
block.addItem(line);
|
|
155
|
+
expect(block.touched(selectionExtremesTrue)).toBe(true);
|
|
156
|
+
expect(block.touched(selectionExtremesFalse)).toBe(false);
|
|
157
|
+
});
|