mxdraw 0.1.2 → 0.1.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/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +2 -0
- package/dist/lib/MxModule/McGeVector3d/index.js +3 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +213 -0
- package/dist/lib/MxModule/MxDbAlignedDimension/index.js +5 -0
- package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +45 -19
- package/dist/lib/MxModule/MxDbImage/MxDbImage.js +150 -0
- package/dist/lib/MxModule/MxDbImage/index.js +5 -0
- package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +208 -0
- package/dist/lib/MxModule/MxDbSVG/index.js +5 -0
- package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +41 -44
- package/dist/lib/MxModule/MxFun/MxFun.js +66 -29
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +6 -1
- package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +2 -2
- package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +4 -4
- package/dist/lib/MxModule/Mxassembly/Mxassembly.js +18 -0
- package/dist/lib/MxModule/Mxassembly/index.js +9 -0
- package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +14 -0
- package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1519 -0
- package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +83 -80
- package/dist/lib/MxModule/store/store.js +1 -0
- package/dist/lib/mxdraw.js +15 -2
- package/dist/lib/types/Mxassembly.js +2 -0
- package/dist/mxdraw.es5.js +3 -3
- package/dist/mxdraw.es5.js.map +1 -1
- package/dist/mxdraw.umd.js +3 -3
- package/dist/mxdraw.umd.js.map +1 -1
- package/dist/types/MxModule/McGeVector3d/McGeVector3d.d.ts +17 -0
- package/dist/types/MxModule/McGeVector3d/index.d.ts +3 -0
- package/dist/types/MxModule/McGiWorldDraw/McGiWorldDraw.d.ts +61 -65
- package/dist/types/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.d.ts +21 -0
- package/dist/types/MxModule/MxDbAlignedDimension/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +46 -25
- package/dist/types/MxModule/MxDbImage/MxDbImage.d.ts +28 -0
- package/dist/types/MxModule/MxDbImage/index.d.ts +3 -0
- package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +42 -0
- package/dist/types/MxModule/MxDbSVG/index.d.ts +3 -0
- package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +38 -39
- package/dist/types/MxModule/MxFun/MxFun.d.ts +57 -26
- package/dist/types/MxModule/MxThreeJS/MxThreeJS.d.ts +2 -2
- package/dist/types/MxModule/MxType/index.d.ts +1 -1
- package/dist/types/MxModule/Mxassembly/Mxassembly.d.ts +11 -0
- package/dist/types/MxModule/Mxassembly/index.d.ts +3 -0
- package/dist/types/MxModule/loadCoreCode/mxcadassembly_es5.d.ts +1 -0
- package/dist/types/MxModule/store/store.d.ts +2 -0
- package/dist/types/mxdraw.d.ts +11 -1
- package/dist/types/types/MxDrawObject.d.ts +2 -2
- package/dist/types/types/MxFun.d.ts +7 -4
- package/dist/types/types/Mxassembly.d.ts +3 -0
- package/package.json +3 -3
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3
|
+
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
4
|
+
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
|
|
5
|
+
//此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
|
|
6
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
7
|
+
/** @module MxDbSVG*/
|
|
8
|
+
var __extends = (this && this.__extends) || (function () {
|
|
9
|
+
var extendStatics = function (d, b) {
|
|
10
|
+
extendStatics = Object.setPrototypeOf ||
|
|
11
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
12
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
13
|
+
return extendStatics(d, b);
|
|
14
|
+
};
|
|
15
|
+
return function (d, b) {
|
|
16
|
+
if (typeof b !== "function" && b !== null)
|
|
17
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
18
|
+
extendStatics(d, b);
|
|
19
|
+
function __() { this.constructor = d; }
|
|
20
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
21
|
+
};
|
|
22
|
+
})();
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
var THREE = require("three");
|
|
25
|
+
var MxDbEntity_1 = require("../MxDbEntity");
|
|
26
|
+
var MxFun_1 = require("../MxFun");
|
|
27
|
+
var MxThreeJS_1 = require("../MxThreeJS");
|
|
28
|
+
var MxType_1 = require("../MxType");
|
|
29
|
+
/**
|
|
30
|
+
* MxDbSVG SVG对象.
|
|
31
|
+
*/
|
|
32
|
+
var MxDbSVG = /** @class */ (function (_super) {
|
|
33
|
+
__extends(MxDbSVG, _super);
|
|
34
|
+
function MxDbSVG() {
|
|
35
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
+
_this.svgPos = new THREE.Vector3();
|
|
37
|
+
_this.svgPath = '';
|
|
38
|
+
_this.svgSize = new THREE.Vector2(50, 50);
|
|
39
|
+
_this.svgAlignmentRatio = new THREE.Vector2(0, 0);
|
|
40
|
+
_this.isSvgDirtyLocation = false;
|
|
41
|
+
_this.isLoadFromPath = true;
|
|
42
|
+
_this.txtPos = new THREE.Vector3();
|
|
43
|
+
_this.txt = '';
|
|
44
|
+
_this.txtHeight = 1;
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
MxDbSVG.prototype.worldDraw = function (pWorldDraw) {
|
|
48
|
+
this.calcSvgPosition();
|
|
49
|
+
if (this.txt.length > 0) {
|
|
50
|
+
var posTxt = new THREE.Vector3(this.txtPos.x, this.txtPos.y, 0);
|
|
51
|
+
pWorldDraw.drawText(this.txt, this.txtHeight, 0, posTxt);
|
|
52
|
+
}
|
|
53
|
+
var svgPosX = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
|
|
54
|
+
var svgPosY = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
|
|
55
|
+
var pt1 = new THREE.Vector3(svgPosX, svgPosY, 0);
|
|
56
|
+
var pt2 = new THREE.Vector3(svgPosX + this.svgSize.x, svgPosY + this.svgSize.y, 0);
|
|
57
|
+
if (pWorldDraw.getType() == 1) {
|
|
58
|
+
if (this.svg) {
|
|
59
|
+
pWorldDraw.drawEntity(this.svg);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (this.svgPath.length > 0 && this.isLoadFromPath) {
|
|
63
|
+
var myThis_1 = this;
|
|
64
|
+
MxThreeJS_1.default.loadSVG(this.svgPath, undefined, function (obj) {
|
|
65
|
+
if (obj) {
|
|
66
|
+
var box = new THREE.Box3().setFromObject(obj);
|
|
67
|
+
obj.scale.x = myThis_1.svgSize.x / (box.max.x - box.min.x);
|
|
68
|
+
obj.scale.y = myThis_1.svgSize.y / (box.max.y - box.min.y);
|
|
69
|
+
obj.scale.z = obj.scale.x;
|
|
70
|
+
myThis_1.isSvgDirtyLocation = true;
|
|
71
|
+
obj.traverse(function (child) {
|
|
72
|
+
if (child.material) {
|
|
73
|
+
child.material.transparent = true;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//this.svgPos.multiply
|
|
77
|
+
myThis_1.svg = obj;
|
|
78
|
+
myThis_1.setNeedUpdateDisplay(true);
|
|
79
|
+
MxFun_1.default.updateDisplay();
|
|
80
|
+
}
|
|
81
|
+
myThis_1.isLoadFromPath = false;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
pWorldDraw.drawSelectLine(pt1.x, pt1.y, pt2.x, pt2.y);
|
|
86
|
+
pWorldDraw.drawSelectLine(pt1.x, pt2.y, pt2.x, pt1.y);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
pWorldDraw.drawLine(pt1.x, pt1.y, pt1.x, pt2.y);
|
|
90
|
+
pWorldDraw.drawLine(pt1.x, pt2.y, pt2.x, pt2.y);
|
|
91
|
+
pWorldDraw.drawLine(pt2.x, pt2.y, pt2.x, pt1.y);
|
|
92
|
+
pWorldDraw.drawLine(pt2.x, pt1.y, pt1.x, pt1.y);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
MxDbSVG.prototype.setSvgPath = function (path) {
|
|
96
|
+
this.svgPath = path;
|
|
97
|
+
this.svg = null;
|
|
98
|
+
this.isLoadFromPath = true;
|
|
99
|
+
};
|
|
100
|
+
MxDbSVG.prototype.getSvgPath = function () {
|
|
101
|
+
return this.svgPath;
|
|
102
|
+
};
|
|
103
|
+
MxDbSVG.prototype.setSvgPostion = function (pos) {
|
|
104
|
+
this.svgPos = pos;
|
|
105
|
+
this.isSvgDirtyLocation = true;
|
|
106
|
+
};
|
|
107
|
+
MxDbSVG.prototype.getSvgPostion = function () {
|
|
108
|
+
return this.svgPos;
|
|
109
|
+
};
|
|
110
|
+
MxDbSVG.prototype.setSvgSize = function (size) {
|
|
111
|
+
this.svgSize = size;
|
|
112
|
+
this.isSvgDirtyLocation = true;
|
|
113
|
+
};
|
|
114
|
+
MxDbSVG.prototype.getSvgSize = function () {
|
|
115
|
+
return this.svgSize;
|
|
116
|
+
};
|
|
117
|
+
MxDbSVG.prototype.setSvgAlignmentRatio = function (alignmentRatio) {
|
|
118
|
+
this.svgAlignmentRatio = alignmentRatio;
|
|
119
|
+
this.isSvgDirtyLocation = true;
|
|
120
|
+
};
|
|
121
|
+
MxDbSVG.prototype.getSvgAlignmentRatio = function () {
|
|
122
|
+
return this.svgAlignmentRatio;
|
|
123
|
+
};
|
|
124
|
+
//
|
|
125
|
+
MxDbSVG.prototype.setTextHeight = function (height) {
|
|
126
|
+
this.txtHeight = height;
|
|
127
|
+
};
|
|
128
|
+
MxDbSVG.prototype.getTextHeight = function () {
|
|
129
|
+
return this.txtHeight;
|
|
130
|
+
};
|
|
131
|
+
MxDbSVG.prototype.setText = function (txt) {
|
|
132
|
+
this.txt = txt;
|
|
133
|
+
};
|
|
134
|
+
MxDbSVG.prototype.getText = function () {
|
|
135
|
+
return this.txt;
|
|
136
|
+
};
|
|
137
|
+
MxDbSVG.prototype.setTextPostion = function (pos) {
|
|
138
|
+
this.txtPos = pos;
|
|
139
|
+
};
|
|
140
|
+
MxDbSVG.prototype.getTextPostion = function () {
|
|
141
|
+
return this.txtPos;
|
|
142
|
+
};
|
|
143
|
+
MxDbSVG.prototype.getGripPoints = function () {
|
|
144
|
+
var ret = [];
|
|
145
|
+
ret.push(this.svgPos);
|
|
146
|
+
return ret;
|
|
147
|
+
};
|
|
148
|
+
MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
|
|
149
|
+
if (index == 0) {
|
|
150
|
+
this.svgPos.add(offset);
|
|
151
|
+
this.txtPos.add(offset);
|
|
152
|
+
}
|
|
153
|
+
this.isSvgDirtyLocation = true;
|
|
154
|
+
return true;
|
|
155
|
+
};
|
|
156
|
+
MxDbSVG.prototype.calcSvgPosition = function () {
|
|
157
|
+
if (!this.svg || !this.isSvgDirtyLocation) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.isSvgDirtyLocation = false;
|
|
161
|
+
this.svg.position.x = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
|
|
162
|
+
this.svg.position.y = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
|
|
163
|
+
};
|
|
164
|
+
MxDbSVG.prototype.dwgIn = function (obj) {
|
|
165
|
+
this.onDwgIn(obj);
|
|
166
|
+
if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
|
|
167
|
+
this.svg = obj['svg'].clone();
|
|
168
|
+
}
|
|
169
|
+
this.svgPos.copy(obj['svgPos']);
|
|
170
|
+
this.svgPath = obj['svgPath'].substr(0);
|
|
171
|
+
this.svgSize.copy(obj['svgSize']);
|
|
172
|
+
this.svgAlignmentRatio.copy(obj['svgAlignmentRatio']);
|
|
173
|
+
this.isSvgDirtyLocation = true;
|
|
174
|
+
if (!this.svg)
|
|
175
|
+
this.isLoadFromPath = true;
|
|
176
|
+
this.txt = obj['txt'];
|
|
177
|
+
this.txtHeight = obj['txtHeight'];
|
|
178
|
+
this.txtPos.copy(obj['txtPos']);
|
|
179
|
+
return true;
|
|
180
|
+
};
|
|
181
|
+
MxDbSVG.prototype.dwgOut = function (obj) {
|
|
182
|
+
this.onDwgOut(obj);
|
|
183
|
+
if (obj.type == MxType_1.default.MxCloneType.kClone) {
|
|
184
|
+
obj['svg'] = this.svg;
|
|
185
|
+
}
|
|
186
|
+
obj['svgPath'] = this.svgPath;
|
|
187
|
+
obj['svgPos'] = this.svgPos;
|
|
188
|
+
obj['svgSize'] = this.svgSize;
|
|
189
|
+
obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
|
|
190
|
+
obj['txt'] = this.txt;
|
|
191
|
+
obj['txtHeight'] = this.txtHeight;
|
|
192
|
+
obj['txtPos'] = this.txtPos;
|
|
193
|
+
return obj;
|
|
194
|
+
};
|
|
195
|
+
MxDbSVG.prototype.create = function () {
|
|
196
|
+
return new MxDbSVG();
|
|
197
|
+
};
|
|
198
|
+
MxDbSVG.prototype.transformBy = function (mat) {
|
|
199
|
+
this.svgPos.applyMatrix4(mat);
|
|
200
|
+
this.txtPos.applyMatrix4(mat);
|
|
201
|
+
this.isSvgDirtyLocation = true;
|
|
202
|
+
};
|
|
203
|
+
MxDbSVG.prototype.getTypeName = function () {
|
|
204
|
+
return 'MxDbSVG';
|
|
205
|
+
};
|
|
206
|
+
return MxDbSVG;
|
|
207
|
+
}(MxDbEntity_1.default));
|
|
208
|
+
exports.default = MxDbSVG;
|
|
@@ -326,8 +326,8 @@ var MxDrawObject = /** @class */ (function () {
|
|
|
326
326
|
*
|
|
327
327
|
* ```
|
|
328
328
|
*/
|
|
329
|
-
MxDrawObject.prototype.screenCoord2Doc = function (x, y
|
|
330
|
-
return this._mxdrawObj.screenCoord2Doc(x, y,
|
|
329
|
+
MxDrawObject.prototype.screenCoord2Doc = function (x, y) {
|
|
330
|
+
return this._mxdrawObj.screenCoord2Doc(x, y, 0);
|
|
331
331
|
};
|
|
332
332
|
/**
|
|
333
333
|
* ThreeJS坐标长度到DWG文档坐标长度
|
|
@@ -410,8 +410,8 @@ var MxDrawObject = /** @class */ (function () {
|
|
|
410
410
|
*
|
|
411
411
|
* ```
|
|
412
412
|
*/
|
|
413
|
-
MxDrawObject.prototype.docCoord2Screen = function (x, y
|
|
414
|
-
return this._mxdrawObj.docCoord2Screen(x, y,
|
|
413
|
+
MxDrawObject.prototype.docCoord2Screen = function (x, y) {
|
|
414
|
+
return this._mxdrawObj.docCoord2Screen(x, y, 0);
|
|
415
415
|
};
|
|
416
416
|
/**
|
|
417
417
|
* 屏幕坐标长度到DWG文档坐标长度
|
|
@@ -500,26 +500,26 @@ var MxDrawObject = /** @class */ (function () {
|
|
|
500
500
|
return this._mxdrawObj.getMxAllSelect();
|
|
501
501
|
};
|
|
502
502
|
/**
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
503
|
+
* 把对象添加到当前选择中.
|
|
504
|
+
* @returns void
|
|
505
|
+
* @example
|
|
506
|
+
* ```typescript
|
|
507
|
+
*
|
|
508
|
+
*
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
511
|
MxDrawObject.prototype.addMxCurrentSelect = function (id) {
|
|
512
512
|
return this._mxdrawObj.addMxCurrentSelect(id);
|
|
513
513
|
};
|
|
514
514
|
/**
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
515
|
+
* 清除当前所有选择
|
|
516
|
+
* @returns void
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
*
|
|
520
|
+
*
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
523
|
MxDrawObject.prototype.clearMxCurrentSelect = function () {
|
|
524
524
|
return this._mxdrawObj.clearMxCurrentSelect();
|
|
525
525
|
};
|
|
@@ -538,8 +538,7 @@ var MxDrawObject = /** @class */ (function () {
|
|
|
538
538
|
};
|
|
539
539
|
/**
|
|
540
540
|
* 查找某点位置处的用户自绘对象.
|
|
541
|
-
* @param ptMouse 查找的点位 THREE.Vector3
|
|
542
|
-
* @param isWorldCoord 点是否是默认坐标 默认为 true
|
|
541
|
+
* @param ptMouse 查找的点位 THREE.Vector3,默认是文档坐标
|
|
543
542
|
* @returns MxDbEntity[] 返回用户自绘对象数组
|
|
544
543
|
* @example
|
|
545
544
|
* ```typescript
|
|
@@ -547,10 +546,8 @@ var MxDrawObject = /** @class */ (function () {
|
|
|
547
546
|
*
|
|
548
547
|
* ```
|
|
549
548
|
*/
|
|
550
|
-
MxDrawObject.prototype.findMxEntityAtPoint = function (ptMouse
|
|
551
|
-
|
|
552
|
-
isWorldCoord = true;
|
|
553
|
-
return this._mxdrawObj.findMxEntityAtPoint(ptMouse, isWorldCoord);
|
|
549
|
+
MxDrawObject.prototype.findMxEntityAtPoint = function (ptMouse) {
|
|
550
|
+
return this._mxdrawObj.findMxEntityAtPoint(ptMouse);
|
|
554
551
|
};
|
|
555
552
|
/**
|
|
556
553
|
*得到所有用户自绘对象.
|
|
@@ -655,28 +652,28 @@ var MxDrawObject = /** @class */ (function () {
|
|
|
655
652
|
return this._mxdrawObj.saveMxEntityToJson();
|
|
656
653
|
};
|
|
657
654
|
/**
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
655
|
+
* 从json字符串恢复MxEntity
|
|
656
|
+
* @param dataString json字符串.
|
|
657
|
+
* @returns
|
|
658
|
+
* @example
|
|
659
|
+
* ```typescript
|
|
660
|
+
*
|
|
661
|
+
*
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
667
664
|
MxDrawObject.prototype.loadMxEntityFromJson = function (dataString) {
|
|
668
665
|
return this._mxdrawObj.loadMxEntityFromJson(dataString);
|
|
669
666
|
};
|
|
670
667
|
/**
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
668
|
+
* 删除所有对MxEntity
|
|
669
|
+
* @param
|
|
670
|
+
* @returns
|
|
671
|
+
* @example
|
|
672
|
+
* ```typescript
|
|
673
|
+
*
|
|
674
|
+
*
|
|
675
|
+
* ```
|
|
676
|
+
*/
|
|
680
677
|
MxDrawObject.prototype.eraseAllMxEntity = function () {
|
|
681
678
|
return this._mxdrawObj.eraseAllMxEntity();
|
|
682
679
|
};
|
|
@@ -50,7 +50,7 @@ var MxFun = /** @class */ (function () {
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
MxFun.prototype.createMxObject = function (_a) {
|
|
53
|
-
var _b = _a.canvasId, canvasId = _b === void 0 ? (0, random_1.createReandomId)() : _b, _c = _a.cadFile, cadFile = _c === void 0 ? '
|
|
53
|
+
var _b = _a.canvasId, canvasId = _b === void 0 ? (0, random_1.createReandomId)() : _b, _c = _a.cadFile, cadFile = _c === void 0 ? '' : _c, callback = _a.callback, _d = _a.isNewFile, isNewFile = _d === void 0 ? true : _d;
|
|
54
54
|
// 获取canvas和其父级
|
|
55
55
|
var canvas = (0, create_1.createCanvas)(canvasId);
|
|
56
56
|
var canvasParent = (0, create_1.createCanvasParent)(canvas);
|
|
@@ -200,6 +200,32 @@ var MxFun = /** @class */ (function () {
|
|
|
200
200
|
MxFun.prototype.screenCoordLong2World = function (len) {
|
|
201
201
|
return store_1.default.state.MxFun.screenCoordLong2World(len);
|
|
202
202
|
};
|
|
203
|
+
/**
|
|
204
|
+
* 屏幕坐标长度转文档坐标长度
|
|
205
|
+
* @param len 屏幕坐标长度
|
|
206
|
+
* @return number 文档坐标长度
|
|
207
|
+
* @example
|
|
208
|
+
* ``` typescript
|
|
209
|
+
* const len = Mx.MxFun.screenCoordLong2Doc(36)
|
|
210
|
+
* console.log(len)
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
MxFun.prototype.screenCoordLong2Doc = function (len) {
|
|
214
|
+
return store_1.default.state.MxFun.screenCoordLong2Doc(len);
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* 文档坐标长度转屏幕坐标长度
|
|
218
|
+
* @param len 文档坐标长度
|
|
219
|
+
* @return number 屏幕坐标长度
|
|
220
|
+
* @example
|
|
221
|
+
* ``` typescript
|
|
222
|
+
* const len = Mx.MxFun.docCoordLong2Screen(36)
|
|
223
|
+
* console.log(len)
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
MxFun.prototype.docCoordLong2Screen = function (len) {
|
|
227
|
+
return store_1.default.state.MxFun.docCoordLong2Screen(len);
|
|
228
|
+
};
|
|
203
229
|
/**
|
|
204
230
|
* THREE.JS坐标长度转屏幕坐标长度
|
|
205
231
|
* @param len THREE.JS坐标长度
|
|
@@ -214,14 +240,14 @@ var MxFun = /** @class */ (function () {
|
|
|
214
240
|
return store_1.default.state.MxFun.worldCoordLong2Doc(len);
|
|
215
241
|
};
|
|
216
242
|
/**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
243
|
+
* DWG文档坐标长度到ThreeJS坐标长度
|
|
244
|
+
* @returns number
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
*
|
|
248
|
+
*
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
225
251
|
MxFun.prototype.docCoordLong2World = function (l) {
|
|
226
252
|
return store_1.default.state.MxFun.docCoordLong2World(l);
|
|
227
253
|
};
|
|
@@ -298,8 +324,8 @@ var MxFun = /** @class */ (function () {
|
|
|
298
324
|
* console.log(vector3)
|
|
299
325
|
* ```
|
|
300
326
|
*/
|
|
301
|
-
MxFun.prototype.screenCoord2Doc = function (x, y
|
|
302
|
-
return store_1.default.state.MxFun.screenCoord2Doc(x, y,
|
|
327
|
+
MxFun.prototype.screenCoord2Doc = function (x, y) {
|
|
328
|
+
return store_1.default.state.MxFun.screenCoord2Doc(x, y, 0);
|
|
303
329
|
};
|
|
304
330
|
/**
|
|
305
331
|
* 文档转屏幕坐标.
|
|
@@ -313,8 +339,8 @@ var MxFun = /** @class */ (function () {
|
|
|
313
339
|
* console.log(vector3)
|
|
314
340
|
* ```
|
|
315
341
|
*/
|
|
316
|
-
MxFun.prototype.docCoord2Screen = function (x, y
|
|
317
|
-
return store_1.default.state.MxFun.docCoord2Screen(x, y,
|
|
342
|
+
MxFun.prototype.docCoord2Screen = function (x, y) {
|
|
343
|
+
return store_1.default.state.MxFun.docCoord2Screen(x, y, 0);
|
|
318
344
|
};
|
|
319
345
|
/**
|
|
320
346
|
* 更新显示,使用Three.js绘制了对象,调用该函数更新显示。
|
|
@@ -488,22 +514,22 @@ var MxFun = /** @class */ (function () {
|
|
|
488
514
|
return store_1.default.state.MxFun.loadImageMaterial(imageUrlPath, callResult);
|
|
489
515
|
};
|
|
490
516
|
/**
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
517
|
+
* 判断点是否在一个闭合的多边形区域。
|
|
518
|
+
* @param p
|
|
519
|
+
* @return any
|
|
520
|
+
* @example
|
|
521
|
+
* ``` typescript
|
|
522
|
+
* let aryPoint:Array<THREE.Vector3> = [];
|
|
523
|
+
* aryPoint.push(new THREE.Vector3(0,0,0));
|
|
524
|
+
* aryPoint.push(new THREE.Vector3(0,100,0));
|
|
525
|
+
* aryPoint.push(new THREE.Vector3(100,100,0));
|
|
526
|
+
* aryPoint.push(new THREE.Vector3(100,0,0));
|
|
527
|
+
* let pt:THREE.Vector3 = new THREE.Vector3(150,150);
|
|
528
|
+
* if(MxFun.pointInPolyline(pt,aryPoint) ){
|
|
529
|
+
* console.log("in");
|
|
530
|
+
* }
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
507
533
|
MxFun.prototype.pointInPolyline = function (pt, vecPolyline) {
|
|
508
534
|
return store_1.default.state.MxFun.pointInPolyline(pt, vecPolyline);
|
|
509
535
|
};
|
|
@@ -518,6 +544,17 @@ var MxFun = /** @class */ (function () {
|
|
|
518
544
|
MxFun.prototype.calcArea = function (aryPoint) {
|
|
519
545
|
return store_1.default.state.MxFun.calcArea(aryPoint);
|
|
520
546
|
};
|
|
547
|
+
/**
|
|
548
|
+
* 重新打开cad文件,该函数在控件创建完后,需要再次重新打开文件,调用。
|
|
549
|
+
* @param sFile 打的cad文件路径
|
|
550
|
+
* @return any
|
|
551
|
+
* @example
|
|
552
|
+
* ``` typescript
|
|
553
|
+
* ```
|
|
554
|
+
*/
|
|
555
|
+
MxFun.prototype.openFile = function (sFile) {
|
|
556
|
+
return store_1.default.state.MxFun.openFile(sFile);
|
|
557
|
+
};
|
|
521
558
|
return MxFun;
|
|
522
559
|
}());
|
|
523
560
|
exports.default = MxFun;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
4
|
+
//版权所有(C)2002-2022,成都梦想凯德科技有限公司。
|
|
5
|
+
//本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
|
|
6
|
+
//此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
|
|
7
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
3
8
|
var three_1 = require("three");
|
|
4
9
|
var math_1 = require("../../tools/algorithm/math");
|
|
5
10
|
var formatting_1 = require("../../tools/formatting");
|
|
@@ -139,7 +144,7 @@ var MxThreeJS = /** @class */ (function () {
|
|
|
139
144
|
context.font = sFont;
|
|
140
145
|
context.textAlign = 'center';
|
|
141
146
|
context.textBaseline = 'middle';
|
|
142
|
-
context.fillStyle = (0, formatting_1.formatString)('rgba({0}, {1}, {2}, 1.0)', ((iColor >> 16) & 0xff) +
|
|
147
|
+
context.fillStyle = (0, formatting_1.formatString)('rgba({0}, {1}, {2}, 1.0)', ((iColor >> 16) & 0xff) + '', ((iColor >> 8) & 0xff) + '', (iColor & 0xff) + '');
|
|
143
148
|
//const sColor = formatString('#{0}', iColor.toString(16))
|
|
144
149
|
context.fillText(message, textWidth / 2, textHeight / 2);
|
|
145
150
|
var texture = new three_1.Texture(canvas);
|
|
@@ -88,7 +88,7 @@ var MxThreeJSBuffer = /** @class */ (function () {
|
|
|
88
88
|
else {
|
|
89
89
|
this.loadSVGImp(url, color, function (group, aryMeterial) {
|
|
90
90
|
if (group && aryMeterial) {
|
|
91
|
-
var data_1 = new MxThreeJSSVGData;
|
|
91
|
+
var data_1 = new MxThreeJSSVGData();
|
|
92
92
|
data_1.svg = group;
|
|
93
93
|
data_1.aryMeterial = aryMeterial;
|
|
94
94
|
_this.mapSvgUrlToData.set(url, data_1);
|
|
@@ -104,7 +104,7 @@ var MxThreeJSBuffer = /** @class */ (function () {
|
|
|
104
104
|
return MxThreeJSBuffer;
|
|
105
105
|
}());
|
|
106
106
|
function default_1(MxThreeJS) {
|
|
107
|
-
var mxThreeJsBuffer = new MxThreeJSBuffer;
|
|
107
|
+
var mxThreeJsBuffer = new MxThreeJSBuffer();
|
|
108
108
|
MxThreeJS.createImage = function (pos, w, h, imageUrlPath, callResult) {
|
|
109
109
|
new three_1.TextureLoader().load(imageUrlPath, function (texture) {
|
|
110
110
|
var geometry = new three_1.PlaneGeometry(w, h);
|
|
@@ -1185,13 +1185,13 @@ var SVGLoader = /** @class */ (function (_super) {
|
|
|
1185
1185
|
var center = new three_1.Vector2();
|
|
1186
1186
|
boundingBox.getCenter(center);
|
|
1187
1187
|
var allIntersections = [];
|
|
1188
|
-
paths
|
|
1188
|
+
paths.forEach(function (path) {
|
|
1189
1189
|
// check if the center of the bounding box is in the bounding box of the paths.
|
|
1190
1190
|
// this is a pruning method to limit the search of intersections in paths that can't envelop of the current path.
|
|
1191
1191
|
// if a path envelops another path. The center of that oter path, has to be inside the bounding box of the enveloping path.
|
|
1192
1192
|
if (path.boundingBox.containsPoint(center)) {
|
|
1193
1193
|
var intersections = getIntersections(scanline, path.points);
|
|
1194
|
-
intersections
|
|
1194
|
+
intersections.forEach(function (p) {
|
|
1195
1195
|
allIntersections.push({ identifier: path.identifier, isCW: path.isCW, point: p });
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
@@ -1307,13 +1307,13 @@ var SVGLoader = /** @class */ (function (_super) {
|
|
|
1307
1307
|
// check if path is solid or a hole
|
|
1308
1308
|
var isAHole = simplePaths.map(function (p) { return isHoleTo(p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule); });
|
|
1309
1309
|
var shapesToReturn = [];
|
|
1310
|
-
simplePaths
|
|
1310
|
+
simplePaths.forEach(function (p) {
|
|
1311
1311
|
var amIAHole = isAHole[p.identifier];
|
|
1312
1312
|
if (!amIAHole.isHole) {
|
|
1313
1313
|
var shape_1 = new three_1.Shape();
|
|
1314
1314
|
shape_1.curves = p.curves;
|
|
1315
1315
|
var holes = isAHole.filter(function (h) { return h.isHole && h.for === p.identifier; });
|
|
1316
|
-
holes
|
|
1316
|
+
holes.forEach(function (h) {
|
|
1317
1317
|
var hole = simplePaths[h.identifier];
|
|
1318
1318
|
var path = new three_1.Path();
|
|
1319
1319
|
path.curves = hole.curves;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var store_1 = require("../store/store");
|
|
4
|
+
/**
|
|
5
|
+
* Mxassembly 模块
|
|
6
|
+
* 导出库时已实例化,只需要调用实例方法 例如:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
var Mxassembly = /** @class */ (function () {
|
|
11
|
+
function Mxassembly() {
|
|
12
|
+
}
|
|
13
|
+
Mxassembly.prototype.NewMcGeVector3d = function () {
|
|
14
|
+
return new store_1.default.state.Mxassembly.McGeVector3d();
|
|
15
|
+
};
|
|
16
|
+
return Mxassembly;
|
|
17
|
+
}());
|
|
18
|
+
exports.default = Mxassembly;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Mxassembly_1 = require("./Mxassembly");
|
|
4
|
+
// import store from '../store/_index'
|
|
5
|
+
// import loadCoreCode from '../loadCoreCode'
|
|
6
|
+
// if (!store.state.MxFUn) {
|
|
7
|
+
// loadCoreCode()
|
|
8
|
+
// }
|
|
9
|
+
exports.default = new Mxassembly_1.default();
|
|
@@ -40,6 +40,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
40
40
|
var dynamicImport_1 = require("../../tools/dynamicImport");
|
|
41
41
|
var store_1 = require("../store/store");
|
|
42
42
|
var mxfun_es5_js_1 = require("./mxfun.es5.js");
|
|
43
|
+
var mxcadassembly_es5_js_1 = require("./mxcadassembly_es5.js");
|
|
44
|
+
var MxDbImage_1 = require("../MxDbImage");
|
|
45
|
+
var MxDbSVG_1 = require("../MxDbSVG");
|
|
46
|
+
var MxDbAlignedDimension_1 = require("../MxDbAlignedDimension");
|
|
47
|
+
function rxInitMxEntity() {
|
|
48
|
+
new MxDbImage_1.default().rxInit();
|
|
49
|
+
new MxDbSVG_1.default().rxInit();
|
|
50
|
+
new MxDbAlignedDimension_1.default().rxInit();
|
|
51
|
+
}
|
|
43
52
|
/**
|
|
44
53
|
* 加载MxDraw库的核心代码 才能使用Mx的其他模块
|
|
45
54
|
* @returns Promise<{@link MxFun}>
|
|
@@ -85,9 +94,14 @@ function loadCoreCode() {
|
|
|
85
94
|
window.MxMain = function (requireFun) {
|
|
86
95
|
store_1.default.events.emit('MxMain', requireFun);
|
|
87
96
|
window.MxMain = undefined;
|
|
97
|
+
rxInitMxEntity();
|
|
88
98
|
res();
|
|
89
99
|
return 0;
|
|
90
100
|
};
|
|
101
|
+
(0, mxcadassembly_es5_js_1.default)().then(function (mxassembly) {
|
|
102
|
+
//console.log(mxassembly);
|
|
103
|
+
store_1.default.commit('setMxassembly', mxassembly);
|
|
104
|
+
});
|
|
91
105
|
// 加载mxfun.min.js,mxfun()相当直接模拟了mxfun.min.js的加载。
|
|
92
106
|
(0, mxfun_es5_js_1.default)();
|
|
93
107
|
return [3 /*break*/, 3];
|