fl-web-component 2.0.19 → 2.1.1-beta.1
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/dist/fl-web-component.common.1.js.map +1 -1
- package/dist/fl-web-component.common.2.js.map +1 -1
- package/dist/fl-web-component.common.js +5871 -1872
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +4 -3
- package/packages/components/com-flcanvas/components/entityFormatting.js +134 -1
- package/packages/components/com-flcanvas/index.vue +335 -239
- package/packages/components/com-graphics/index.vue +433 -35
- package/packages/components/com-graphics/mock.json +115 -0
- package/packages/utils/StreamLoader.js +250 -107
- package/packages/utils/StreamLoaderParser.worker.js +180 -72
- package/src/utils/dxf-parser/AutoCadColorIndex.js +265 -0
- package/src/utils/dxf-parser/DimStyleCodes.js +33 -0
- package/src/utils/dxf-parser/DxfArrayScanner.js +151 -0
- package/src/utils/dxf-parser/DxfParser.js +918 -0
- package/src/utils/dxf-parser/ExtendedDataParser.js +117 -0
- package/src/utils/dxf-parser/LICENSE +21 -0
- package/src/utils/dxf-parser/ParseHelpers.js +140 -0
- package/src/utils/dxf-parser/README.md +8 -0
- package/src/utils/dxf-parser/entities/3dface.js +83 -0
- package/src/utils/dxf-parser/entities/arc.js +38 -0
- package/src/utils/dxf-parser/entities/attdef.js +89 -0
- package/src/utils/dxf-parser/entities/attribute.js +109 -0
- package/src/utils/dxf-parser/entities/circle.js +43 -0
- package/src/utils/dxf-parser/entities/dimension.js +71 -0
- package/src/utils/dxf-parser/entities/ellipse.js +48 -0
- package/src/utils/dxf-parser/entities/hatch.js +348 -0
- package/src/utils/dxf-parser/entities/insert.js +57 -0
- package/src/utils/dxf-parser/entities/line.js +34 -0
- package/src/utils/dxf-parser/entities/lwpolyline.js +103 -0
- package/src/utils/dxf-parser/entities/mtext.js +57 -0
- package/src/utils/dxf-parser/entities/point.js +35 -0
- package/src/utils/dxf-parser/entities/polyline.js +92 -0
- package/src/utils/dxf-parser/entities/solid.js +40 -0
- package/src/utils/dxf-parser/entities/spline.js +70 -0
- package/src/utils/dxf-parser/entities/text.js +50 -0
- package/src/utils/dxf-parser/entities/vertex.js +62 -0
- package/src/utils/flgltf-parser.js +21 -9
- package/src/utils/instance-parser.js +59 -59
- package/src/utils/threejs/measure-clear-distance.js +149 -123
- package/packages/components/com-graphics/box.json +0 -77
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import log from "loglevel"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default class ExtendedDataParser {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
this.appName = null
|
|
8
|
+
this.appNameWarningShown = false
|
|
9
|
+
this.lastString = null
|
|
10
|
+
this.sectionStack = [this._CreateSection()]
|
|
11
|
+
this.failure = false
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Feed next token.
|
|
16
|
+
* @return {boolean} True if new parser instance should be created for this token.
|
|
17
|
+
*/
|
|
18
|
+
Feed(curr) {
|
|
19
|
+
if (!this.appName) {
|
|
20
|
+
if (curr.code == 1001) {
|
|
21
|
+
this.appName = curr.value
|
|
22
|
+
return false
|
|
23
|
+
}
|
|
24
|
+
if (!this.appNameWarningShown) {
|
|
25
|
+
this.appNameWarningShown = true
|
|
26
|
+
log.warn("XDATA section does not start with application name")
|
|
27
|
+
}
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (curr.code == 1001) {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (this.failure) {
|
|
36
|
+
/* Ignore all the rest content in case of parsing failure. */
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (curr.code == 1000) {
|
|
41
|
+
if (this.lastString) {
|
|
42
|
+
log.warn("XDATA section unused string: " + this.lastString)
|
|
43
|
+
}
|
|
44
|
+
this.lastString = curr.value
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const curSection = this._currentSection
|
|
49
|
+
|
|
50
|
+
if (curr.code == 1002) {
|
|
51
|
+
if (curr.value == "{") {
|
|
52
|
+
if (!this.lastString) {
|
|
53
|
+
log.warn("Unnamed XDATA section encountered")
|
|
54
|
+
this.failure = true
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
const newSection = this._CreateSection()
|
|
58
|
+
curSection[this.lastString] = newSection
|
|
59
|
+
this.lastString = null
|
|
60
|
+
this.sectionStack.push(newSection)
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
if (curr.value == "}") {
|
|
64
|
+
if (this.sectionStack.length < 2) {
|
|
65
|
+
log.warn("Unmatched XDATA section closing")
|
|
66
|
+
this.failure = true
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
this.sectionStack.length = this.sectionStack.length - 1
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
log.warn("Bad XDATA section control string encountered: " + curr.value)
|
|
73
|
+
this.failure = true
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (this.lastString !== null) {
|
|
78
|
+
curSection.values.push(this._CreateValue(1000, this.lastString))
|
|
79
|
+
this.lastString = null
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
curSection.values.push(this._CreateValue(curr.code, curr.value))
|
|
83
|
+
|
|
84
|
+
return false
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Finalize XDATA section parsing. */
|
|
88
|
+
Finish(entity) {
|
|
89
|
+
if (this.failure) {
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
if (this.appName) {
|
|
93
|
+
let xdata
|
|
94
|
+
if (entity.hasOwnProperty("xdata")) {
|
|
95
|
+
xdata = entity.xdata
|
|
96
|
+
} else {
|
|
97
|
+
xdata = {}
|
|
98
|
+
entity.xdata = xdata
|
|
99
|
+
}
|
|
100
|
+
xdata[this.appName] = this.sectionStack[0]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get _currentSection() {
|
|
105
|
+
return this.sectionStack[this.sectionStack.length - 1]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_CreateSection() {
|
|
109
|
+
return {
|
|
110
|
+
values: []
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_CreateValue(code, value) {
|
|
115
|
+
return {code, value}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 GDS Storefront Estimating
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import AUTO_CAD_COLOR_INDEX from "./AutoCadColorIndex.js";
|
|
2
|
+
import ExtendedDataParser from "./ExtendedDataParser.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns the truecolor value of the given AutoCad color index value
|
|
6
|
+
* @return {Number} truecolor value as a number
|
|
7
|
+
*/
|
|
8
|
+
export function getAcadColor(index) {
|
|
9
|
+
return AUTO_CAD_COLOR_INDEX[index];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parses the 2D or 3D coordinate, vector, or point. When complete,
|
|
14
|
+
* the scanner remains on the last group of the coordinate.
|
|
15
|
+
* @param {*} scanner
|
|
16
|
+
*/
|
|
17
|
+
export function parsePoint(scanner) {
|
|
18
|
+
var point = {};
|
|
19
|
+
|
|
20
|
+
// Reread group for the first coordinate
|
|
21
|
+
scanner.rewind();
|
|
22
|
+
var curr = scanner.next();
|
|
23
|
+
|
|
24
|
+
var code = curr.code;
|
|
25
|
+
point.x = curr.value;
|
|
26
|
+
|
|
27
|
+
code += 10;
|
|
28
|
+
curr = scanner.next();
|
|
29
|
+
if(curr.code !== code)
|
|
30
|
+
throw new Error('Expected code for point value to be ' + code +
|
|
31
|
+
' but got ' + curr.code + '.');
|
|
32
|
+
point.y = curr.value;
|
|
33
|
+
|
|
34
|
+
code += 10;
|
|
35
|
+
curr = scanner.next();
|
|
36
|
+
if(curr.code !== code)
|
|
37
|
+
{
|
|
38
|
+
// Only the x and y are specified. Don't read z.
|
|
39
|
+
scanner.rewind(); // Let the calling code advance off the point
|
|
40
|
+
return point;
|
|
41
|
+
}
|
|
42
|
+
point.z = curr.value;
|
|
43
|
+
|
|
44
|
+
return point;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Some entities may contain embedded object which is started by group 101. All the rest data until
|
|
48
|
+
* end of entity should not be interpreted as entity attributes. There is no documentation for this
|
|
49
|
+
* feature.
|
|
50
|
+
* @param scanner
|
|
51
|
+
*/
|
|
52
|
+
export function skipEmbeddedObject(scanner) {
|
|
53
|
+
/* Ensure proper start group. */
|
|
54
|
+
scanner.rewind()
|
|
55
|
+
let curr = scanner.next()
|
|
56
|
+
if (curr.code !== 101) {
|
|
57
|
+
throw new Error("Bad call for skipEmbeddedObject()")
|
|
58
|
+
}
|
|
59
|
+
do {
|
|
60
|
+
curr = scanner.next()
|
|
61
|
+
} while (curr.code !== 0)
|
|
62
|
+
scanner.rewind()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Attempts to parse codes common to all entities. Returns true if the group
|
|
67
|
+
* was handled by this function.
|
|
68
|
+
* @param {*} entity - the entity currently being parsed
|
|
69
|
+
* @param {*} curr - the current group being parsed
|
|
70
|
+
*/
|
|
71
|
+
export function checkCommonEntityProperties(entity, curr, scanner) {
|
|
72
|
+
let xdataParser = null
|
|
73
|
+
while (curr.code >= 1000) {
|
|
74
|
+
if (xdataParser == null) {
|
|
75
|
+
xdataParser = new ExtendedDataParser()
|
|
76
|
+
}
|
|
77
|
+
if (xdataParser.Feed(curr)) {
|
|
78
|
+
xdataParser.Finish(entity)
|
|
79
|
+
xdataParser = null
|
|
80
|
+
} else {
|
|
81
|
+
curr = scanner.next()
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (xdataParser) {
|
|
85
|
+
xdataParser.Finish(entity)
|
|
86
|
+
/* Groups following XDATA should be parsed on next iteration. */
|
|
87
|
+
scanner.rewind()
|
|
88
|
+
return true
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
switch(curr.code) {
|
|
92
|
+
case 0:
|
|
93
|
+
entity.type = curr.value;
|
|
94
|
+
break;
|
|
95
|
+
case 5:
|
|
96
|
+
entity.handle = curr.value;
|
|
97
|
+
break;
|
|
98
|
+
case 6:
|
|
99
|
+
entity.lineType = curr.value;
|
|
100
|
+
break;
|
|
101
|
+
case 8: // Layer name
|
|
102
|
+
entity.layer = curr.value;
|
|
103
|
+
break;
|
|
104
|
+
case 48:
|
|
105
|
+
entity.lineTypeScale = curr.value;
|
|
106
|
+
break;
|
|
107
|
+
case 60:
|
|
108
|
+
entity.hidden = !!curr.value;
|
|
109
|
+
break;
|
|
110
|
+
case 62: // Acad Index Color. 0 inherits ByBlock. 256 inherits ByLayer. Default is bylayer
|
|
111
|
+
entity.colorIndex = curr.value;
|
|
112
|
+
entity.color = getAcadColor(Math.abs(curr.value));
|
|
113
|
+
break;
|
|
114
|
+
case 67:
|
|
115
|
+
entity.inPaperSpace = curr.value !== 0;
|
|
116
|
+
break;
|
|
117
|
+
case 100:
|
|
118
|
+
//ignore
|
|
119
|
+
break;
|
|
120
|
+
case 330:
|
|
121
|
+
entity.ownerHandle = curr.value;
|
|
122
|
+
break;
|
|
123
|
+
case 347:
|
|
124
|
+
entity.materialObjectHandle = curr.value;
|
|
125
|
+
break;
|
|
126
|
+
case 370:
|
|
127
|
+
//From https://www.woutware.com/Forum/Topic/955/lineweight?returnUrl=%2FForum%2FUserPosts%3FuserId%3D478262319
|
|
128
|
+
// An integer representing 100th of mm, must be one of the following values:
|
|
129
|
+
// 0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, 211.
|
|
130
|
+
// -3 = STANDARD, -2 = BYLAYER, -1 = BYBLOCK
|
|
131
|
+
entity.lineweight = curr.value;
|
|
132
|
+
break;
|
|
133
|
+
case 420: // TrueColor Color
|
|
134
|
+
entity.color = curr.value;
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
It is a fork of https://github.com/gdsestimating/dxf-parser. We need it to make some improvements
|
|
2
|
+
over the original code:
|
|
3
|
+
* Support additional DXF groups.
|
|
4
|
+
* Stream parsing - parse text as it is fetched without buffering. This allows parsing huge files
|
|
5
|
+
with limited memory consumption.
|
|
6
|
+
* Result filtering - do not include data which is not needed on further processing steps, filtering
|
|
7
|
+
it on-the-fly, thus minimizing memory consumption even more.
|
|
8
|
+
* Additional features support (e.g. hatching).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = '3DFACE';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
|
|
10
|
+
var entity = { type: curr.value, vertices: [] };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while (curr !== 'EOF') {
|
|
13
|
+
if (curr.code === 0) break;
|
|
14
|
+
switch (curr.code) {
|
|
15
|
+
case 70: // 1 = Closed shape, 128 = plinegen?, 0 = default
|
|
16
|
+
entity.shape = ((curr.value & 1) === 1);
|
|
17
|
+
entity.hasContinuousLinetypePattern = ((curr.value & 128) === 128);
|
|
18
|
+
break;
|
|
19
|
+
case 10: // X coordinate of point
|
|
20
|
+
entity.vertices = parse3dFaceVertices(scanner, curr);
|
|
21
|
+
curr = scanner.lastReadGroup;
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
curr = scanner.next();
|
|
28
|
+
}
|
|
29
|
+
return entity;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function parse3dFaceVertices(scanner, curr) {
|
|
33
|
+
var vertices = [],
|
|
34
|
+
i;
|
|
35
|
+
var vertexIsStarted = false;
|
|
36
|
+
var vertexIsFinished = false;
|
|
37
|
+
var verticesPer3dFace = 4; // there can be up to four vertices per face, although 3 is most used for TIN
|
|
38
|
+
|
|
39
|
+
for (i = 0; i <= verticesPer3dFace; i++) {
|
|
40
|
+
var vertex = {};
|
|
41
|
+
while (curr !== 'EOF') {
|
|
42
|
+
if (curr.code === 0 || vertexIsFinished) break;
|
|
43
|
+
|
|
44
|
+
switch (curr.code) {
|
|
45
|
+
case 10: // X0
|
|
46
|
+
case 11: // X1
|
|
47
|
+
case 12: // X2
|
|
48
|
+
case 13: // X3
|
|
49
|
+
if (vertexIsStarted) {
|
|
50
|
+
vertexIsFinished = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
vertex.x = curr.value;
|
|
54
|
+
vertexIsStarted = true;
|
|
55
|
+
break;
|
|
56
|
+
case 20: // Y
|
|
57
|
+
case 21:
|
|
58
|
+
case 22:
|
|
59
|
+
case 23:
|
|
60
|
+
vertex.y = curr.value;
|
|
61
|
+
break;
|
|
62
|
+
case 30: // Z
|
|
63
|
+
case 31:
|
|
64
|
+
case 32:
|
|
65
|
+
case 33:
|
|
66
|
+
vertex.z = curr.value;
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
// it is possible to have entity codes after the vertices.
|
|
70
|
+
// So if code is not accounted for return to entity parser where it might be accounted for
|
|
71
|
+
return vertices;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
curr = scanner.next();
|
|
75
|
+
}
|
|
76
|
+
// See https://groups.google.com/forum/#!topic/comp.cad.autocad/9gn8s5O_w6E
|
|
77
|
+
vertices.push(vertex);
|
|
78
|
+
vertexIsStarted = false;
|
|
79
|
+
vertexIsFinished = false;
|
|
80
|
+
}
|
|
81
|
+
scanner.rewind();
|
|
82
|
+
return vertices;
|
|
83
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'ARC';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity, endAngle;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 10: // X coordinate of point
|
|
17
|
+
entity.center = helpers.parsePoint(scanner);
|
|
18
|
+
break;
|
|
19
|
+
case 40: // radius
|
|
20
|
+
entity.radius = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 50: // start angle
|
|
23
|
+
entity.startAngle = Math.PI / 180 * curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 51: // end angle
|
|
26
|
+
entity.endAngle = Math.PI / 180 * curr.value;
|
|
27
|
+
break;
|
|
28
|
+
case 210:
|
|
29
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
30
|
+
break;
|
|
31
|
+
default: // ignored attribute
|
|
32
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
curr = scanner.next();
|
|
36
|
+
}
|
|
37
|
+
return entity;
|
|
38
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as helpers from "../ParseHelpers.js";
|
|
2
|
+
|
|
3
|
+
export default function EntityParser() {}
|
|
4
|
+
|
|
5
|
+
EntityParser.ForEntityName = 'ATTDEF';
|
|
6
|
+
|
|
7
|
+
EntityParser.prototype.parseEntity = function (scanner, curr) {
|
|
8
|
+
var entity = {
|
|
9
|
+
type: curr.value,
|
|
10
|
+
scale: 1,
|
|
11
|
+
textStyle: 'STANDARD',
|
|
12
|
+
};
|
|
13
|
+
curr = scanner.next();
|
|
14
|
+
while (curr !== 'EOF') {
|
|
15
|
+
if (curr.code === 0) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
switch (curr.code) {
|
|
19
|
+
case 1:
|
|
20
|
+
entity.text = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 2:
|
|
23
|
+
entity.tag = curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 3:
|
|
26
|
+
entity.prompt = curr.value;
|
|
27
|
+
break;
|
|
28
|
+
case 7:
|
|
29
|
+
entity.textStyle = curr.value;
|
|
30
|
+
break;
|
|
31
|
+
case 10: // X coordinate of 'first alignment point'
|
|
32
|
+
entity.startPoint = helpers.parsePoint(scanner);
|
|
33
|
+
break;
|
|
34
|
+
case 11: // X coordinate of 'second alignment point'
|
|
35
|
+
entity.endPoint = helpers.parsePoint(scanner);
|
|
36
|
+
break;
|
|
37
|
+
case 39:
|
|
38
|
+
entity.thickness = curr.value;
|
|
39
|
+
break;
|
|
40
|
+
case 40:
|
|
41
|
+
entity.textHeight = curr.value;
|
|
42
|
+
break;
|
|
43
|
+
case 41:
|
|
44
|
+
entity.scale = curr.value;
|
|
45
|
+
break;
|
|
46
|
+
case 50:
|
|
47
|
+
entity.rotation = curr.value;
|
|
48
|
+
break;
|
|
49
|
+
case 51:
|
|
50
|
+
entity.obliqueAngle = curr.value;
|
|
51
|
+
break;
|
|
52
|
+
case 70:
|
|
53
|
+
entity.hidden = !!(curr.value & 0x01);
|
|
54
|
+
entity.constant = !!(curr.value & 0x02);
|
|
55
|
+
entity.verificationRequired = !!(curr.value & 0x04);
|
|
56
|
+
entity.preset = !!(curr.value & 0x08);
|
|
57
|
+
break;
|
|
58
|
+
case 71:
|
|
59
|
+
entity.backwards = !!(curr.value & 0x02);
|
|
60
|
+
entity.mirrored = !!(curr.value & 0x04);
|
|
61
|
+
break;
|
|
62
|
+
case 72:
|
|
63
|
+
// TODO: enum values?
|
|
64
|
+
entity.horizontalJustification = curr.value;
|
|
65
|
+
break;
|
|
66
|
+
case 73:
|
|
67
|
+
entity.fieldLength = curr.value;
|
|
68
|
+
break;
|
|
69
|
+
case 74:
|
|
70
|
+
// TODO: enum values?
|
|
71
|
+
entity.verticalJustification = curr.value;
|
|
72
|
+
break;
|
|
73
|
+
case 100:
|
|
74
|
+
break;
|
|
75
|
+
case 101:
|
|
76
|
+
helpers.skipEmbeddedObject(scanner);
|
|
77
|
+
break;
|
|
78
|
+
case 210:
|
|
79
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
80
|
+
break;
|
|
81
|
+
default:
|
|
82
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
curr = scanner.next();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return entity;
|
|
89
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as helpers from "../ParseHelpers.js";
|
|
2
|
+
|
|
3
|
+
export default function EntityParser() {}
|
|
4
|
+
|
|
5
|
+
EntityParser.ForEntityName = 'ATTRIB';
|
|
6
|
+
|
|
7
|
+
EntityParser.prototype.parseEntity = function (scanner, curr) {
|
|
8
|
+
var entity = {
|
|
9
|
+
type: curr.value,
|
|
10
|
+
scale: 1,
|
|
11
|
+
textStyle: 'STANDARD',
|
|
12
|
+
};
|
|
13
|
+
curr = scanner.next();
|
|
14
|
+
while (curr !== 'EOF') {
|
|
15
|
+
if (curr.code === 0) {
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
switch (curr.code) {
|
|
19
|
+
case 1:
|
|
20
|
+
entity.text = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 2:
|
|
23
|
+
entity.tag = curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 3:
|
|
26
|
+
entity.prompt = curr.value;
|
|
27
|
+
break;
|
|
28
|
+
case 7:
|
|
29
|
+
entity.textStyle = curr.value;
|
|
30
|
+
break;
|
|
31
|
+
case 10: // X coordinate of 'first alignment point'
|
|
32
|
+
entity.startPoint = helpers.parsePoint(scanner);
|
|
33
|
+
break;
|
|
34
|
+
case 11: // X coordinate of 'second alignment point'
|
|
35
|
+
entity.endPoint = helpers.parsePoint(scanner);
|
|
36
|
+
break;
|
|
37
|
+
case 39:
|
|
38
|
+
entity.thickness = curr.value;
|
|
39
|
+
break;
|
|
40
|
+
case 40:
|
|
41
|
+
entity.textHeight = curr.value;
|
|
42
|
+
break;
|
|
43
|
+
case 41:
|
|
44
|
+
entity.scale = curr.value;
|
|
45
|
+
break;
|
|
46
|
+
case 44:
|
|
47
|
+
entity.lineSpacingFactor = curr.value;
|
|
48
|
+
break;
|
|
49
|
+
case 45:
|
|
50
|
+
entity.fillBoxScale = curr.value;
|
|
51
|
+
break;
|
|
52
|
+
case 46:
|
|
53
|
+
entity.annotationHeight = curr.value;
|
|
54
|
+
break;
|
|
55
|
+
case 50:
|
|
56
|
+
entity.rotation = curr.value;
|
|
57
|
+
break;
|
|
58
|
+
case 51:
|
|
59
|
+
entity.obliqueAngle = curr.value;
|
|
60
|
+
break;
|
|
61
|
+
case 63:
|
|
62
|
+
entity.backgroundFillColor = curr.value;
|
|
63
|
+
break;
|
|
64
|
+
case 70:
|
|
65
|
+
entity.hidden = !!(curr.value & 0x01);
|
|
66
|
+
entity.constant = !!(curr.value & 0x02);
|
|
67
|
+
entity.verificationRequired = !!(curr.value & 0x04);
|
|
68
|
+
entity.preset = !!(curr.value & 0x08);
|
|
69
|
+
break;
|
|
70
|
+
case 71:
|
|
71
|
+
entity.attachmentPoint = curr.value;
|
|
72
|
+
break;
|
|
73
|
+
case 72:
|
|
74
|
+
entity.horizontalJustification = curr.value;
|
|
75
|
+
break;
|
|
76
|
+
case 73:
|
|
77
|
+
entity.lineSpacing = curr.value;
|
|
78
|
+
break;
|
|
79
|
+
case 74:
|
|
80
|
+
entity.verticalJustification = curr.value;
|
|
81
|
+
break;
|
|
82
|
+
case 90:
|
|
83
|
+
// TODO:: enum
|
|
84
|
+
// 0 = Background fill off
|
|
85
|
+
// 1 = Use background fill color
|
|
86
|
+
// 2 = Use drawing window color as background fill color
|
|
87
|
+
// and 420 ~ 439 background color check
|
|
88
|
+
entity.backgroundFillSetting = curr.value;
|
|
89
|
+
break;
|
|
90
|
+
case 100:
|
|
91
|
+
break;
|
|
92
|
+
case 210:
|
|
93
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
94
|
+
break;
|
|
95
|
+
case 280:
|
|
96
|
+
entity.lockPositionFlag = curr.value;
|
|
97
|
+
break;
|
|
98
|
+
case 340:
|
|
99
|
+
entity.hardPointerId = curr.value;
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
curr = scanner.next();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return entity;
|
|
109
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import * as helpers from "../ParseHelpers.js"
|
|
3
|
+
|
|
4
|
+
export default function EntityParser() {}
|
|
5
|
+
|
|
6
|
+
EntityParser.ForEntityName = 'CIRCLE';
|
|
7
|
+
|
|
8
|
+
EntityParser.prototype.parseEntity = function(scanner, curr) {
|
|
9
|
+
var entity, endAngle;
|
|
10
|
+
entity = { type: curr.value };
|
|
11
|
+
curr = scanner.next();
|
|
12
|
+
while(curr !== 'EOF') {
|
|
13
|
+
if(curr.code === 0) break;
|
|
14
|
+
|
|
15
|
+
switch(curr.code) {
|
|
16
|
+
case 10: // X coordinate of point
|
|
17
|
+
entity.center = helpers.parsePoint(scanner);
|
|
18
|
+
break;
|
|
19
|
+
case 40: // radius
|
|
20
|
+
entity.radius = curr.value;
|
|
21
|
+
break;
|
|
22
|
+
case 50: // start angle
|
|
23
|
+
entity.startAngle = Math.PI / 180 * curr.value;
|
|
24
|
+
break;
|
|
25
|
+
case 51: // end angle
|
|
26
|
+
endAngle = Math.PI / 180 * curr.value;
|
|
27
|
+
if(endAngle < entity.startAngle)
|
|
28
|
+
entity.angleLength = endAngle + 2 * Math.PI - entity.startAngle;
|
|
29
|
+
else
|
|
30
|
+
entity.angleLength = endAngle - entity.startAngle;
|
|
31
|
+
entity.endAngle = endAngle;
|
|
32
|
+
break;
|
|
33
|
+
case 210:
|
|
34
|
+
entity.extrusionDirection = helpers.parsePoint(scanner);
|
|
35
|
+
break;
|
|
36
|
+
default: // ignored attribute
|
|
37
|
+
helpers.checkCommonEntityProperties(entity, curr, scanner);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
curr = scanner.next();
|
|
41
|
+
}
|
|
42
|
+
return entity;
|
|
43
|
+
};
|