fl-web-component 0.1.1 → 1.0.0
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.js +14751 -54489
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/dist/fl-web-component.umd.js +14751 -54489
- package/dist/fl-web-component.umd.js.map +1 -1
- package/dist/fl-web-component.umd.min.js +3 -3
- package/dist/fl-web-component.umd.min.js.map +1 -1
- package/package.json +26 -5
- package/packages/components/button/index.vue +18 -17
- package/packages/components/com-card/card-page.vue +51 -49
- package/packages/components/com-card/index.vue +20 -21
- package/packages/components/com-dialogWrapper/index.vue +18 -21
- package/packages/components/com-flcanvas/components/bspline.js +91 -0
- package/packages/components/com-flcanvas/components/entityFormatting.js +503 -0
- package/packages/components/com-flcanvas/components/round10.js +24 -0
- package/packages/components/com-flcanvas/index.vue +259 -0
- package/packages/components/com-formDialog/index.vue +76 -75
- package/packages/components/com-graphics/index.vue +1059 -226
- package/packages/components/com-graphics/per-control.vue +109 -0
- package/packages/components/com-graphics/pid.vue +168 -0
- package/packages/components/com-page/index.vue +33 -33
- package/packages/components/com-selectTree/index.vue +61 -63
- package/packages/components/com-table/column-default.vue +9 -14
- package/packages/components/com-table/column-dynamic.vue +4 -8
- package/packages/components/com-table/column-menu.vue +8 -8
- package/packages/components/com-table/column-slot.vue +4 -4
- package/packages/components/com-table/column.vue +7 -15
- package/packages/components/com-table/config.js +9 -9
- package/packages/components/com-table/index.vue +35 -35
- package/packages/components/com-table/table-page.vue +17 -17
- package/packages/components/com-tabs/index.vue +19 -19
- package/packages/components/com-treeDynamic/index.vue +45 -45
- package/packages/components/model/api/index.js +59 -67
- package/packages/components/model/api/mock/detecttree.js +38 -38
- package/packages/components/model/api/mock/getmodel-line.js +15830 -79332
- package/packages/components/model/api/mock/init.js +1 -1
- package/packages/components/model/api/mock/pbstree.js +486 -495
- package/packages/components/model/components/TextOverTooltip/index.vue +3 -3
- package/packages/components/model/components/annotation-toolbar.vue +4 -19
- package/packages/components/model/components/check-proofing-model.vue +26 -29
- package/packages/components/model/components/clipping-type.vue +22 -14
- package/packages/components/model/components/com-dialogWrapper/index.vue +22 -25
- package/packages/components/model/components/detect-panel.vue +38 -26
- package/packages/components/model/components/detect-tree.vue +9 -24
- package/packages/components/model/components/firstPer-panel.vue +23 -25
- package/packages/components/model/components/header-button.vue +31 -107
- package/packages/components/model/components/imageViewer/index.vue +34 -35
- package/packages/components/model/components/import-model.vue +127 -127
- package/packages/components/model/components/location-panel.vue +25 -29
- package/packages/components/model/components/measure-type.vue +15 -15
- package/packages/components/model/components/pbs-tree.vue +139 -144
- package/packages/components/model/components/proof-config.vue +2 -10
- package/packages/components/model/components/proof-for-pc.vue +35 -32
- package/packages/components/model/components/proof-history.vue +136 -154
- package/packages/components/model/components/proof-panel-detail.vue +166 -165
- package/packages/components/model/components/proof-panel.vue +281 -205
- package/packages/components/model/components/proof-project-user.vue +13 -50
- package/packages/components/model/components/proof-publish.vue +130 -130
- package/packages/components/model/components/proof-role.vue +93 -124
- package/packages/components/model/components/props-panel.vue +63 -54
- package/packages/components/model/index.vue +3225 -3213
- package/packages/components/model/utils/annotation-tool.js +75 -82
- package/packages/components/model/utils/cursor.js +15 -10
- package/packages/components/model/utils/detect-v1.js +23 -35
- package/packages/components/model/utils/index.js +25 -25
- package/packages/components/model/utils/threejs/measure-angle.js +180 -180
- package/packages/components/model/utils/threejs/measure-area.js +196 -184
- package/packages/components/model/utils/threejs/measure-distance.js +154 -152
- package/packages/components/model/utils/threejs/measure-volume.js +64 -61
- package/src/assets/test.png +0 -0
- package/src/assets/worker.glb +0 -0
- package/src/main.js +11 -8
- package/src/utils/flgltf-parser.js +141 -0
- package/src/utils/instance-parser.js +402 -0
- package/src/utils/mock.js +84746 -0
- package/src/utils/threejs/measure-angle.js +240 -0
- package/src/utils/threejs/measure-area.js +249 -0
- package/src/utils/threejs/measure-distance.js +195 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
import bSpline from "./bspline";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
|
|
4
|
+
export function handleFn(functionName, recordDxf, entity, group, key, configParams, konvaLayer) {
|
|
5
|
+
switch (functionName) {
|
|
6
|
+
case 'LINE': drawLine(recordDxf, entity, group, key, configParams)
|
|
7
|
+
break;
|
|
8
|
+
case 'TEXT': drawText(recordDxf, entity, group, key, configParams)
|
|
9
|
+
break;
|
|
10
|
+
case 'LWPOLYLINE': drawLwLine(recordDxf, entity, group, key, configParams)
|
|
11
|
+
break;
|
|
12
|
+
case 'ARC': drawArc(recordDxf, entity, group, key, configParams)
|
|
13
|
+
break;
|
|
14
|
+
case 'CIRCLE': drawArc(recordDxf, entity, group, key, configParams)
|
|
15
|
+
break;
|
|
16
|
+
case 'ELLIPSE': drawEllpse(recordDxf, entity, group, key, configParams)
|
|
17
|
+
break;
|
|
18
|
+
//case 'MTEXT': drawMtext(recordDxf, entity, group, key, configParams)
|
|
19
|
+
//break;
|
|
20
|
+
case 'SPLINE': drawSpline(recordDxf, entity, group, key, configParams)
|
|
21
|
+
break;
|
|
22
|
+
// case 'INSERT': drawInsert(recordDxf, entity, group, key, configParams, konvaLayer)
|
|
23
|
+
// break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function formatEntity(entities) {
|
|
27
|
+
var obj = {}
|
|
28
|
+
for (let i = 0; i < entities.length; i++) {
|
|
29
|
+
if (obj.hasOwnProperty(entities[i].layer)) {
|
|
30
|
+
obj[entities[i].layer].push(entities[i])
|
|
31
|
+
} else {
|
|
32
|
+
obj[entities[i].layer] = []
|
|
33
|
+
obj[entities[i].layer].push(entities[i])
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return obj
|
|
37
|
+
}
|
|
38
|
+
export function getAbsolutePoints(points) {
|
|
39
|
+
let x = 0;
|
|
40
|
+
let y = 0;
|
|
41
|
+
points.forEach((point, index) => {
|
|
42
|
+
if (index % 2 === 0) {
|
|
43
|
+
x = x + point;
|
|
44
|
+
} else {
|
|
45
|
+
y = y + point;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
x: Math.ceil(x / (points.length / 2)),
|
|
50
|
+
y: Math.ceil(y / (points.length / 2)),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function getColors() {
|
|
54
|
+
return colors;
|
|
55
|
+
}
|
|
56
|
+
// 居中定位
|
|
57
|
+
export function centering(obj, container, konvaStage, scaleBy) {
|
|
58
|
+
// 由于图纸结构解析的变更 可能最外层的group x y 都是0所以 需要拿到x y有值的group
|
|
59
|
+
const filterGroup = obj.filter(item => item.attrs.isGroup && !item.attrs.isMix)
|
|
60
|
+
if (filterGroup.length > 0) {
|
|
61
|
+
if (filterGroup[0].attrs.hasOwnProperty('isBlock') && filterGroup[0].attrs.isBlock) {
|
|
62
|
+
computedCenter(filterGroup[0].attrs.x, filterGroup[0].attrs.y, container, konvaStage, scaleBy)
|
|
63
|
+
} else {
|
|
64
|
+
const target = obj.filter((item) => !item.attrs.isGroup);
|
|
65
|
+
if (target[0].className === "Text") {
|
|
66
|
+
computedCenter(target[0].x(), target[0].y(), container, konvaStage, scaleBy)
|
|
67
|
+
} else if (target[0].className === "Line") {
|
|
68
|
+
const p = getAbsolutePoints(target[0].getPoints());
|
|
69
|
+
computedCenter(p.x, p.y, container, konvaStage, scaleBy)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
const target = obj.filter((item) => !item.attrs.isGroup);
|
|
74
|
+
if (target[0].className === "Text") {
|
|
75
|
+
computedCenter(target[0].x(), target[0].y(), container, konvaStage, scaleBy)
|
|
76
|
+
} else if (target[0].className === "Line") {
|
|
77
|
+
const p = getAbsolutePoints(target[0].getPoints());
|
|
78
|
+
computedCenter(p.x, p.y, container, konvaStage, scaleBy)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// 计算居中位置
|
|
83
|
+
function computedCenter(x, y, container, konvaStage, scaleBy) {
|
|
84
|
+
let newX = container.clientWidth / 2 - x * scaleBy;
|
|
85
|
+
let newY = container.clientHeight / 2 -y * scaleBy;
|
|
86
|
+
konvaStage.position({ x: newX, y: newY });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getBSplinePolyline(
|
|
90
|
+
controlPoints,
|
|
91
|
+
degree,
|
|
92
|
+
knots,
|
|
93
|
+
interpolationsPerSplineSegment,
|
|
94
|
+
weights
|
|
95
|
+
) {
|
|
96
|
+
const polyline = [];
|
|
97
|
+
const controlPointsForLib = controlPoints.map(function (p) {
|
|
98
|
+
return [p.x, p.y];
|
|
99
|
+
});
|
|
100
|
+
const segmentTs = [knots[degree]];
|
|
101
|
+
const domain = [knots[degree], knots[knots.length - 1 - degree]];
|
|
102
|
+
for (let k = degree + 1; k < knots.length - degree; ++k) {
|
|
103
|
+
if (segmentTs[segmentTs.length - 1] !== knots[k]) {
|
|
104
|
+
segmentTs.push(knots[k]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
interpolationsPerSplineSegment = interpolationsPerSplineSegment || 25;
|
|
108
|
+
for (let i = 1; i < segmentTs.length; ++i) {
|
|
109
|
+
const uMin = segmentTs[i - 1];
|
|
110
|
+
const uMax = segmentTs[i];
|
|
111
|
+
for (let k = 0; k <= interpolationsPerSplineSegment; ++k) {
|
|
112
|
+
const u = (k / interpolationsPerSplineSegment) * (uMax - uMin) + uMin;
|
|
113
|
+
let t = (u - domain[0]) / (domain[1] - domain[0]);
|
|
114
|
+
t = Math.max(t, 0);
|
|
115
|
+
t = Math.min(t, 1);
|
|
116
|
+
const p = bSpline(t, degree, controlPointsForLib, knots, weights);
|
|
117
|
+
polyline.push(new THREE.Vector2(p[0], p[1]));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return polyline;
|
|
121
|
+
}
|
|
122
|
+
function mtextContentAndFormattingToTextAndStyle(
|
|
123
|
+
textAndControlChars,
|
|
124
|
+
entity,
|
|
125
|
+
configParams
|
|
126
|
+
) {
|
|
127
|
+
let activeStyle = {
|
|
128
|
+
horizontalAlignment: "left",
|
|
129
|
+
textHeight: entity.height,
|
|
130
|
+
};
|
|
131
|
+
var text = [];
|
|
132
|
+
for (let item of textAndControlChars) {
|
|
133
|
+
if (typeof item === "string") {
|
|
134
|
+
if (item.startsWith("pxq") && item.endsWith(";")) {
|
|
135
|
+
if (item.indexOf("c") !== -1)
|
|
136
|
+
activeStyle.horizontalAlignment = "center";
|
|
137
|
+
else if (item.indexOf("l") !== -1)
|
|
138
|
+
activeStyle.horizontalAlignment = "left";
|
|
139
|
+
else if (item.indexOf("r") !== -1)
|
|
140
|
+
activeStyle.horizontalAlignment = "right";
|
|
141
|
+
else if (item.indexOf("j") !== -1)
|
|
142
|
+
activeStyle.horizontalAlignment = "justify";
|
|
143
|
+
} else {
|
|
144
|
+
text.push(item);
|
|
145
|
+
}
|
|
146
|
+
} else if (Array.isArray(item)) {
|
|
147
|
+
var nestedFormat = mtextContentAndFormattingToTextAndStyle(
|
|
148
|
+
item,
|
|
149
|
+
entity,
|
|
150
|
+
configParams
|
|
151
|
+
);
|
|
152
|
+
text.push(nestedFormat.text);
|
|
153
|
+
} else if (typeof item === "object") {
|
|
154
|
+
if (item["S"] && item["S"].length === 3) {
|
|
155
|
+
text.push(item["S"][0] + "/" + item["S"][2]);
|
|
156
|
+
} else {
|
|
157
|
+
// not yet supported.
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
text: text.join(),
|
|
163
|
+
style: activeStyle,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function drawArc(recordDxf, entity, group, key, configParams) {
|
|
168
|
+
let startAngle, endAngle;
|
|
169
|
+
if (entity.type === "CIRCLE") {
|
|
170
|
+
startAngle = entity.startAngle || 0;
|
|
171
|
+
endAngle = startAngle + 2 * Math.PI;
|
|
172
|
+
} else {
|
|
173
|
+
startAngle = entity.startAngle;
|
|
174
|
+
endAngle = entity.endAngle;
|
|
175
|
+
}
|
|
176
|
+
let curve = new THREE.ArcCurve(
|
|
177
|
+
entity.center.x,
|
|
178
|
+
parseFloat(entity.center.y),
|
|
179
|
+
entity.radius,
|
|
180
|
+
startAngle,
|
|
181
|
+
endAngle
|
|
182
|
+
);
|
|
183
|
+
let points = curve.getPoints(32);
|
|
184
|
+
|
|
185
|
+
let list = [];
|
|
186
|
+
for (let i = 0; i < points.length; i++) {
|
|
187
|
+
list.push(points[i].x);
|
|
188
|
+
list.push(-parseFloat(points[i].y));
|
|
189
|
+
}
|
|
190
|
+
let width = 0.2;
|
|
191
|
+
group.push({
|
|
192
|
+
type:'polyline',
|
|
193
|
+
points:list,
|
|
194
|
+
name: key.replace(/\s*/g, ""),
|
|
195
|
+
entityId: key,
|
|
196
|
+
stroke: configParams ? configParams.color : "#000",
|
|
197
|
+
customColor: configParams ? configParams.color : "",
|
|
198
|
+
strokeWidth: width,
|
|
199
|
+
visible: configParams ? configParams.visible :true,
|
|
200
|
+
oldstrokeLength:width
|
|
201
|
+
});
|
|
202
|
+
// if(group.attrs.isBlock){
|
|
203
|
+
// let scale=group.scale();
|
|
204
|
+
// width=width/Math.abs(scale.x);
|
|
205
|
+
// }
|
|
206
|
+
// let line = new Konva.Line({
|
|
207
|
+
// name: key.replace(/\s*/g, ""),
|
|
208
|
+
// entityId: key,
|
|
209
|
+
// isGroup: false,
|
|
210
|
+
// points: list,
|
|
211
|
+
// stroke: configParams ? configParams.color : "#000",
|
|
212
|
+
// customColor: configParams ? configParams.color : "",
|
|
213
|
+
// strokeWidth: width,
|
|
214
|
+
// lineCap: "round",
|
|
215
|
+
// lineJoin: "round",
|
|
216
|
+
// visible: configParams ? configParams.visible :true,
|
|
217
|
+
// oldstrokeLength:width
|
|
218
|
+
// });
|
|
219
|
+
// group.add(line);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function drawEllpse(recordDxf, entity, group, key, configParams) {
|
|
223
|
+
let xrad = Math.sqrt(
|
|
224
|
+
Math.pow(parseFloat(entity.majorAxisEndPoint.x), 2) +
|
|
225
|
+
Math.pow(parseFloat(entity.majorAxisEndPoint.y), 2)
|
|
226
|
+
);
|
|
227
|
+
let yrad = xrad * parseFloat(entity.axisRatio);
|
|
228
|
+
let rotation = Math.atan2(
|
|
229
|
+
parseFloat(entity.majorAxisEndPoint.y),
|
|
230
|
+
parseFloat(entity.majorAxisEndPoint.x)
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
let curve = new THREE.EllipseCurve(
|
|
234
|
+
parseFloat(entity.center.x),
|
|
235
|
+
parseFloat(entity.center.y),
|
|
236
|
+
xrad,
|
|
237
|
+
yrad,
|
|
238
|
+
parseFloat(entity.startAngle),
|
|
239
|
+
parseFloat(entity.endAngle),
|
|
240
|
+
false, // Always counterclockwise
|
|
241
|
+
rotation
|
|
242
|
+
);
|
|
243
|
+
let points = curve.getPoints(200);
|
|
244
|
+
let list = [];
|
|
245
|
+
for (let i = 0; i < points.length; i++) {
|
|
246
|
+
list.push(points[i].x);
|
|
247
|
+
list.push(-parseFloat(points[i].y));
|
|
248
|
+
}
|
|
249
|
+
let width = 0.2;
|
|
250
|
+
group.push({
|
|
251
|
+
type:'polyline',
|
|
252
|
+
points:list,
|
|
253
|
+
name: key.replace(/\s*/g, ""),
|
|
254
|
+
entityId: key,
|
|
255
|
+
stroke: configParams ? configParams.color : "#000",
|
|
256
|
+
customColor: configParams ? configParams.color : "",
|
|
257
|
+
strokeWidth: width,
|
|
258
|
+
visible: configParams ? configParams.visible : true,
|
|
259
|
+
oldstrokeLength:width
|
|
260
|
+
});
|
|
261
|
+
// let line = new Konva.Line({
|
|
262
|
+
// name: key.replace(/\s*/g, ""),
|
|
263
|
+
// entityId: key,
|
|
264
|
+
// isGroup: false,
|
|
265
|
+
// points: list,
|
|
266
|
+
// stroke: configParams ? configParams.color : "#000",
|
|
267
|
+
// customColor: configParams ? configParams.color : "",
|
|
268
|
+
// strokeWidth: width,
|
|
269
|
+
// lineCap: "round",
|
|
270
|
+
// lineJoin: "round",
|
|
271
|
+
// visible: configParams ? configParams.visible : true,
|
|
272
|
+
// oldstrokeLength:width
|
|
273
|
+
|
|
274
|
+
// });
|
|
275
|
+
// group.add(line);
|
|
276
|
+
}
|
|
277
|
+
function drawLine(recordDxf, entity, group, key, configParams) {
|
|
278
|
+
let x1 = entity.vertices[0].x;
|
|
279
|
+
let y1 = entity.vertices[0].y;
|
|
280
|
+
let x2 = entity.vertices[1].x;
|
|
281
|
+
let y2 = entity.vertices[1].y;
|
|
282
|
+
let width = 0.2;
|
|
283
|
+
group.push({
|
|
284
|
+
type:"line",
|
|
285
|
+
x1:x1,
|
|
286
|
+
x2:x2,
|
|
287
|
+
y1:y1,
|
|
288
|
+
y2:y2,
|
|
289
|
+
name: key.replace(/\s*/g, ""),
|
|
290
|
+
entityId: key,
|
|
291
|
+
isGroup: false,
|
|
292
|
+
stroke: configParams ? configParams.color : "#000",
|
|
293
|
+
customColor: configParams ? configParams.color : "",
|
|
294
|
+
strokeWidth: width,
|
|
295
|
+
visible: configParams ? configParams.visible : true,
|
|
296
|
+
oldstrokeLength:width,
|
|
297
|
+
});
|
|
298
|
+
// if(group.attrs.isBlock){
|
|
299
|
+
// let scale=group.scale();
|
|
300
|
+
// width=width/Math.abs(scale.x);
|
|
301
|
+
// }
|
|
302
|
+
// let line = new Konva.Line({
|
|
303
|
+
// name: key.replace(/\s*/g, ""),
|
|
304
|
+
// entityId: key,
|
|
305
|
+
// isGroup: false,
|
|
306
|
+
// points: [x1, -parseFloat(y1), parseFloat(x2), -parseFloat(y2)],
|
|
307
|
+
// stroke: configParams ? configParams.color : "#000",
|
|
308
|
+
// customColor: configParams ? configParams.color : "",
|
|
309
|
+
// strokeWidth: width,
|
|
310
|
+
// //lineCap: "round",
|
|
311
|
+
// //lineJoin: "round",
|
|
312
|
+
// visible: configParams ? configParams.visible : true,
|
|
313
|
+
// oldstrokeLength:width,
|
|
314
|
+
// handle:entity.handle
|
|
315
|
+
|
|
316
|
+
// });
|
|
317
|
+
|
|
318
|
+
// group.add(line);
|
|
319
|
+
}
|
|
320
|
+
function drawText(recordDxf, entity, group, key, configParams) {
|
|
321
|
+
let text = entity.text;
|
|
322
|
+
let fontSize=0;
|
|
323
|
+
if(key==0){
|
|
324
|
+
fontSize=entity.textHeight+0.35;
|
|
325
|
+
}else{
|
|
326
|
+
fontSize=entity.textHeight+0.35;
|
|
327
|
+
}
|
|
328
|
+
let startPoint = entity.startPoint;
|
|
329
|
+
let x = startPoint.x;
|
|
330
|
+
let y = startPoint.y;
|
|
331
|
+
let dim = new Konva.Text({
|
|
332
|
+
x: parseFloat(x),
|
|
333
|
+
y: -parseFloat(y),
|
|
334
|
+
text: text,
|
|
335
|
+
fontSize: fontSize,
|
|
336
|
+
fill: configParams ? configParams.color : "#000",
|
|
337
|
+
customColor: configParams ? configParams.color : "",
|
|
338
|
+
name: key.replace(/\s*/g, ""),
|
|
339
|
+
entityId: key,
|
|
340
|
+
fontFamily: "SimSun",
|
|
341
|
+
visible: configParams ? configParams.visible : true,
|
|
342
|
+
stroke: configParams ? configParams.color : "#000",
|
|
343
|
+
strokeWidth:0.1,
|
|
344
|
+
});
|
|
345
|
+
if (entity.rotation) {
|
|
346
|
+
|
|
347
|
+
if(entity.rotation==90||parseInt(entity.rotation)==90||parseInt(entity.rotation)==89||parseInt(entity.rotation)==450) {
|
|
348
|
+
dim.attrs.x = parseFloat(x) - fontSize;
|
|
349
|
+
}
|
|
350
|
+
if(entity.rotation==270||parseInt(entity.rotation)==270)
|
|
351
|
+
{
|
|
352
|
+
dim.attrs.x = parseFloat(x) + fontSize;
|
|
353
|
+
}
|
|
354
|
+
if(entity.rotation==180||parseInt(entity.rotation)==180){
|
|
355
|
+
dim.attrs.y= -parseFloat(y) - fontSize;
|
|
356
|
+
}
|
|
357
|
+
if(entity.rotation==360||parseFloat(entity.rotation)==360){
|
|
358
|
+
dim.attrs.y= -parseFloat(y) - fontSize;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
dim.attrs.rotation = 360-entity.rotation ;
|
|
363
|
+
|
|
364
|
+
}else{
|
|
365
|
+
dim.attrs.y= -parseFloat(y) - fontSize;
|
|
366
|
+
}
|
|
367
|
+
if (entity.xScale) {
|
|
368
|
+
dim.attrs.fontSize =(fontSize+0.35)* entity.xScale;
|
|
369
|
+
}
|
|
370
|
+
group.push({
|
|
371
|
+
"type":'text',
|
|
372
|
+
'obj':dim,
|
|
373
|
+
})
|
|
374
|
+
// group.add(dim);
|
|
375
|
+
}
|
|
376
|
+
function drawLwLine(recordDxf, entity, group, key, configParams) {
|
|
377
|
+
let closed = entity.shape;
|
|
378
|
+
let list=[];
|
|
379
|
+
for(let i =0;i<entity.vertices.length;i++){
|
|
380
|
+
list.push(entity.vertices[i].x);
|
|
381
|
+
list.push(-parseFloat(entity.vertices[i].y));
|
|
382
|
+
}
|
|
383
|
+
let width = 0.2;
|
|
384
|
+
if(entity.width){
|
|
385
|
+
width=width+parseFloat(entity.width);
|
|
386
|
+
}else{
|
|
387
|
+
width=0.2;
|
|
388
|
+
}
|
|
389
|
+
group.push({
|
|
390
|
+
type:"polyline",
|
|
391
|
+
points:list,
|
|
392
|
+
closed:closed,
|
|
393
|
+
name: key.replace(/\s*/g, ""),
|
|
394
|
+
entityId: key,
|
|
395
|
+
stroke: configParams ? configParams.color : "#000",
|
|
396
|
+
customColor: configParams ? configParams.color : "",
|
|
397
|
+
strokeWidth: width,
|
|
398
|
+
visible: configParams ? configParams.visible : true,
|
|
399
|
+
oldstrokeLength:width,
|
|
400
|
+
})
|
|
401
|
+
// let line = new Konva.Line({
|
|
402
|
+
// name: key.replace(/\s*/g, ""),
|
|
403
|
+
// entityId: key,
|
|
404
|
+
// isGroup: false,
|
|
405
|
+
// points: list,
|
|
406
|
+
// stroke: configParams ? configParams.color : "#000",
|
|
407
|
+
// customColor: configParams ? configParams.color : "",
|
|
408
|
+
// strokeWidth: width,
|
|
409
|
+
// visible: configParams ? configParams.visible : true,
|
|
410
|
+
// closed:closed,
|
|
411
|
+
// oldstrokeLength:width,
|
|
412
|
+
// handle:entity.handle
|
|
413
|
+
|
|
414
|
+
// });
|
|
415
|
+
// group.add(line);
|
|
416
|
+
}
|
|
417
|
+
function drawSpline(recordDxf, entity, group, key, configParams) {
|
|
418
|
+
let points = getBSplinePolyline(
|
|
419
|
+
entity.controlPoints,
|
|
420
|
+
entity.degreeOfSplineCurve,
|
|
421
|
+
entity.knotValues,
|
|
422
|
+
100
|
|
423
|
+
);
|
|
424
|
+
let list = [];
|
|
425
|
+
for (let i = 0; i < points.length; i++) {
|
|
426
|
+
list.push(points[i].x);
|
|
427
|
+
list.push(-parseFloat(points[i].y));
|
|
428
|
+
}
|
|
429
|
+
let width = 0.1;
|
|
430
|
+
group.push({
|
|
431
|
+
type:'polyline',
|
|
432
|
+
points: list,
|
|
433
|
+
name: key.replace(/\s*/g, ""),
|
|
434
|
+
entityId: key,
|
|
435
|
+
isGroup: false,
|
|
436
|
+
stroke: configParams ? configParams : "#000",
|
|
437
|
+
customColor: configParams ? configParams.color : "",
|
|
438
|
+
strokeWidth: width,
|
|
439
|
+
visible: configParams ? configParams.visible : true,
|
|
440
|
+
oldstrokeLength: width
|
|
441
|
+
});
|
|
442
|
+
// let line = new Konva.Line({
|
|
443
|
+
// name: key.replace(/\s*/g, ""),
|
|
444
|
+
// entityId: key,
|
|
445
|
+
// isGroup: false,
|
|
446
|
+
// points: list,
|
|
447
|
+
// stroke: configParams ? configParams : "#000",
|
|
448
|
+
// customColor: configParams ? configParams.color : "",
|
|
449
|
+
// strokeWidth: width,
|
|
450
|
+
// lineCap: "round",
|
|
451
|
+
// lineJoin: "round",
|
|
452
|
+
// visible: configParams ? configParams.visible : true,
|
|
453
|
+
// oldstrokeLength:width
|
|
454
|
+
// });
|
|
455
|
+
// group.add(line);
|
|
456
|
+
}
|
|
457
|
+
function drawInsert(recordDxf, entities, group, key, configParams, konvaLayer) {
|
|
458
|
+
if (recordDxf.blocks[entities.name]) {
|
|
459
|
+
let group2 = new Konva.Group({
|
|
460
|
+
x: 0,
|
|
461
|
+
y: 0,
|
|
462
|
+
name: key.replace(/\s*/g, ""),
|
|
463
|
+
isBlock: true,
|
|
464
|
+
blockName: entities.name,
|
|
465
|
+
entityId: key,
|
|
466
|
+
isGroup: true,
|
|
467
|
+
visible: true,
|
|
468
|
+
});
|
|
469
|
+
let entity = entities;
|
|
470
|
+
let block = recordDxf.blocks[entities.name];
|
|
471
|
+
if (entity.rotation) {
|
|
472
|
+
group2.rotation(360-entity.rotation);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (entity.xScale) {
|
|
476
|
+
group2.scale({ x: entity.xScale, y: entity.yScale });
|
|
477
|
+
}
|
|
478
|
+
if (entity.yScale) {
|
|
479
|
+
group2.scale({ x: entity.xScale, y: entity.yScale });
|
|
480
|
+
}
|
|
481
|
+
if (entity.position) {
|
|
482
|
+
group2.attrs.x = parseFloat(entity.position.x);
|
|
483
|
+
group2.attrs.y = -parseFloat(entity.position.y);
|
|
484
|
+
}
|
|
485
|
+
if(entity.position.x<0){
|
|
486
|
+
group2.attrs.x = parseFloat(entity.position.x)*-1;
|
|
487
|
+
if(entity.xScale<0){
|
|
488
|
+
group2.scale({ x: Math.abs(entity.xScale), y: entity.yScale });
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if(block.entities==undefined){
|
|
492
|
+
return ;
|
|
493
|
+
}
|
|
494
|
+
for (let j = 0; j < block.entities.length; j++) {
|
|
495
|
+
let type = block.entities[j].type;
|
|
496
|
+
handleFn(type, recordDxf, block.entities[j], group2, key, configParams, konvaLayer)
|
|
497
|
+
}
|
|
498
|
+
group.add(group2)
|
|
499
|
+
// 区分块 因为有的块里面包含块 不区分会对点击定位有影响
|
|
500
|
+
group.attrs.isMix = true
|
|
501
|
+
konvaLayer.add(group)
|
|
502
|
+
}
|
|
503
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// This is based on the example code found from:
|
|
2
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor
|
|
3
|
+
// Example code on MDN is public domain or CC0 (your preference) or MIT depending when the
|
|
4
|
+
// example code was added:
|
|
5
|
+
// https://developer.mozilla.org/en-US/docs/MDN/About
|
|
6
|
+
|
|
7
|
+
export default (value, exp) => {
|
|
8
|
+
// If the exp is undefined or zero...
|
|
9
|
+
if (typeof exp === 'undefined' || +exp === 0) {
|
|
10
|
+
return Math.round(value)
|
|
11
|
+
}
|
|
12
|
+
value = +value
|
|
13
|
+
exp = +exp
|
|
14
|
+
// If the value is not a number or the exp is not an integer...
|
|
15
|
+
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
|
|
16
|
+
return NaN
|
|
17
|
+
}
|
|
18
|
+
// Shift
|
|
19
|
+
value = value.toString().split('e')
|
|
20
|
+
value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)))
|
|
21
|
+
// Shift back
|
|
22
|
+
value = value.toString().split('e')
|
|
23
|
+
return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp))
|
|
24
|
+
}
|