mxdraw 0.1.9 → 0.1.12

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.
Files changed (28) hide show
  1. package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +28 -0
  2. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +2 -1
  3. package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +185 -41
  4. package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +3 -0
  5. package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +74 -2
  6. package/dist/lib/MxModule/MxFun/MxFun.js +51 -2
  7. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +5 -1
  8. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +15 -3
  9. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +9 -10
  10. package/dist/lib/MxModule/loadCoreCode/mxUiData.js +317 -0
  11. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +174 -55
  12. package/dist/lib/tools/dynamicImport/index.js +45 -1
  13. package/dist/mxdraw.es5.js +2 -2
  14. package/dist/mxdraw.es5.js.map +1 -1
  15. package/dist/mxdraw.umd.js +2 -2
  16. package/dist/mxdraw.umd.js.map +1 -1
  17. package/dist/types/MxModule/McGiWorldDraw/McGiWorldDraw.d.ts +1 -1
  18. package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +21 -0
  19. package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +8 -0
  20. package/dist/types/MxModule/MxDbSVGText/MxDbSVGText.d.ts +3 -0
  21. package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +12 -1
  22. package/dist/types/MxModule/MxFun/MxFun.d.ts +13 -1
  23. package/dist/types/MxModule/MxThreeJS/MxThreeJS.d.ts +1 -1
  24. package/dist/types/MxModule/loadCoreCode/mxUiData.d.ts +111 -0
  25. package/dist/types/tools/dynamicImport/index.d.ts +1 -0
  26. package/dist/types/types/MxDrawObject.d.ts +2 -1
  27. package/dist/types/types/MxFun.d.ts +2 -1
  28. package/package.json +1 -1
@@ -79,6 +79,34 @@ var MxDbEntity = /** @class */ (function () {
79
79
  return false;
80
80
  }
81
81
  };
82
+ /**
83
+ * 返回对象所在的控件对象。
84
+ * @param
85
+ * @returns boolean
86
+ * @example
87
+ * ``` typescript
88
+ *
89
+ * ```
90
+ */
91
+ MxDbEntity.prototype.getMxObject = function () {
92
+ var imp = this.getImp();
93
+ if (imp)
94
+ return imp.getMxObject();
95
+ else
96
+ return null;
97
+ };
98
+ /**
99
+ * 视区显示比较发生成变化,继承类可以向应该事件,更新显示大小。
100
+ * @param
101
+ * @returns boolean
102
+ * @example
103
+ * ``` typescript
104
+ *
105
+ * ```
106
+ */
107
+ MxDbEntity.prototype.onViewChange = function () {
108
+ return false;
109
+ };
82
110
  /**
83
111
  * 得到对象的id.
84
112
  * @param
@@ -70,6 +70,7 @@ var MxDbImage = /** @class */ (function (_super) {
70
70
  }
71
71
  else if (this.imagePath.length > 0 && this.isLoadMaterialFromPath) {
72
72
  var myThis_1 = this;
73
+ var mxobj_1 = pWorldDraw.getMxObject();
73
74
  MxFun_1.default.loadImageMaterial(this.imagePath, function (material) {
74
75
  _this.isLoadMaterialFromPath = false;
75
76
  if (!material) {
@@ -77,7 +78,7 @@ var MxDbImage = /** @class */ (function (_super) {
77
78
  }
78
79
  myThis_1.setMaterial(material);
79
80
  myThis_1.setNeedUpdateDisplay();
80
- MxFun_1.default.updateDisplay();
81
+ mxobj_1.updateDisplay();
81
82
  });
82
83
  }
83
84
  }
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- ///////////////////////////////////////////////////////////////////////////////
3
- //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
4
- //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
5
- //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
6
- ///////////////////////////////////////////////////////////////////////////////
7
- /** @module MxDbSVG*/
8
2
  var __extends = (this && this.__extends) || (function () {
9
3
  var extendStatics = function (d, b) {
10
4
  extendStatics = Object.setPrototypeOf ||
@@ -21,10 +15,15 @@ var __extends = (this && this.__extends) || (function () {
21
15
  };
22
16
  })();
23
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ ///////////////////////////////////////////////////////////////////////////////
19
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
20
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
21
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+ /** @module MxDbSVG*/
24
24
  var THREE = require("three");
25
25
  var MxDbEntity_1 = require("../MxDbEntity");
26
26
  var MxDbSVGText_1 = require("../MxDbSVGText");
27
- var MxFun_1 = require("../MxFun");
28
27
  var MxThreeJS_1 = require("../MxThreeJS");
29
28
  var MxType_1 = require("../MxType");
30
29
  /**
@@ -35,78 +34,154 @@ var MxDbSVG = /** @class */ (function (_super) {
35
34
  function MxDbSVG() {
36
35
  var _this = _super !== null && _super.apply(this, arguments) || this;
37
36
  _this.svgPos = new THREE.Vector3();
37
+ _this.svg = null;
38
38
  _this.svgPath = '';
39
39
  _this.svgSize = new THREE.Vector2(50, 50);
40
40
  _this.svgAlignmentRatio = new THREE.Vector2(0, 0);
41
+ _this.svgRotate = 0;
42
+ _this.svgReverse = false;
43
+ _this.svgMargin = new THREE.Vector2(0, 0);
41
44
  _this.isSvgDirtyLocation = false;
42
45
  _this.isLoadFromPath = true;
43
46
  _this.aryText = [];
47
+ _this.svgBoxSize = null;
48
+ // 固定尺寸,图片和文字大小,取屏幕像素绘图单位。
49
+ _this.fixedSize = false;
50
+ _this.useSvgColor = false;
44
51
  return _this;
45
52
  }
53
+ MxDbSVG.prototype.calcVewSize = function (mxObj) {
54
+ var sizew = this.svgSize.x;
55
+ var sizeh = this.svgSize.y;
56
+ if (sizeh <= 0) {
57
+ if (this.svgBoxSize) {
58
+ sizeh = (this.svgBoxSize.y / this.svgBoxSize.x) * sizew;
59
+ }
60
+ else {
61
+ sizeh = sizew;
62
+ }
63
+ }
64
+ if (this.fixedSize) {
65
+ sizew = mxObj.screenCoordLong2Doc(sizew);
66
+ sizeh = mxObj.screenCoordLong2Doc(sizeh);
67
+ }
68
+ return [sizew, sizeh];
69
+ };
46
70
  MxDbSVG.prototype.worldDraw = function (pWorldDraw) {
47
71
  var _this = this;
48
- this.calcSvgPosition();
49
- this.aryText.forEach(function (txt) {
50
- if (txt.txt.length > 0) {
51
- var posTxt = new THREE.Vector3(txt.txtPos.x, txt.txtPos.y, 0);
52
- pWorldDraw.drawText(txt.txt, txt.txtHeight, 0, posTxt);
53
- }
54
- });
55
- var svgPosX = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
56
- var svgPosY = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
57
- var pt1 = new THREE.Vector3(svgPosX, svgPosY, 0);
58
- var pt2 = new THREE.Vector3(svgPosX + this.svgSize.x, svgPosY + this.svgSize.y, 0);
72
+ var mxObj = pWorldDraw.getMxObject();
73
+ this.calcSvgPosition(mxObj);
74
+ var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
75
+ var matSclae = new THREE.Matrix4();
76
+ if (this.svgReverse)
77
+ matSclae.makeScale(1, -1, 1);
78
+ var mat = new THREE.Matrix4();
79
+ mat.makeRotationZ(this.svgRotate);
80
+ var matMove = new THREE.Matrix4();
81
+ var svgNewPos = new THREE.Vector3(this.svgPos.x - sizew * this.svgAlignmentRatio.x, this.svgPos.y - sizeh * this.svgAlignmentRatio.y, 0);
82
+ matMove.makeTranslation(svgNewPos.x, svgNewPos.y, svgNewPos.z);
83
+ mat.multiply(matSclae);
84
+ mat.premultiply(matMove);
85
+ var pt1 = new THREE.Vector3(0, 0, 0);
86
+ var pt3 = new THREE.Vector3(sizew, 0, 0);
87
+ var pt2 = new THREE.Vector3(sizew, sizeh, 0);
88
+ var pt4 = new THREE.Vector3(0, sizeh, 0);
89
+ pt1.applyMatrix4(mat);
90
+ pt3.applyMatrix4(mat);
91
+ pt2.applyMatrix4(mat);
92
+ pt4.applyMatrix4(mat);
59
93
  if (pWorldDraw.getType() == 1) {
94
+ this.aryText.forEach(function (txt) {
95
+ if (txt.txt.length > 0) {
96
+ var posTxt = new THREE.Vector3(txt.txtPos.x, txt.txtPos.y, 0);
97
+ if (_this.fixedSize) {
98
+ if (txt.txtPos.x > 0)
99
+ posTxt.x = _this.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
100
+ else
101
+ posTxt.x = _this.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
102
+ if (txt.txtPos.y > 0)
103
+ posTxt.y = _this.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
104
+ else
105
+ posTxt.y = _this.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
106
+ }
107
+ var bakColor = undefined;
108
+ if (txt.color) {
109
+ bakColor = pWorldDraw.getColor();
110
+ pWorldDraw.setColor(txt.color);
111
+ }
112
+ var iSize = txt.txtHeight;
113
+ if (_this.fixedSize)
114
+ iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
115
+ txt._txtObject = pWorldDraw.drawText(txt.txt, iSize, 0, posTxt);
116
+ txt._txtAspectRatio = -1;
117
+ if (bakColor) {
118
+ pWorldDraw.setColor(bakColor);
119
+ }
120
+ }
121
+ });
60
122
  if (this.svg) {
61
123
  pWorldDraw.drawEntity(this.svg);
62
124
  }
63
125
  else {
64
126
  if (this.svgPath.length > 0 && this.isLoadFromPath) {
65
127
  var myThis_1 = this;
128
+ var mxobj_1 = pWorldDraw.getMxObject();
66
129
  MxThreeJS_1.default.loadSVG(this.svgPath, undefined, function (obj) {
67
130
  if (obj) {
68
131
  var box = new THREE.Box3().setFromObject(obj);
69
- obj.scale.x = myThis_1.svgSize.x / (box.max.x - box.min.x);
70
- obj.scale.y = myThis_1.svgSize.y / (box.max.y - box.min.y);
132
+ if (!myThis_1.svgBoxSize) {
133
+ myThis_1.svgBoxSize = new THREE.Vector3();
134
+ }
135
+ myThis_1.svgBoxSize.x = box.max.x - box.min.x;
136
+ myThis_1.svgBoxSize.y = box.max.y - box.min.y;
137
+ var _a = myThis_1.calcVewSize(mxObj), sizew_1 = _a[0], sizeh_1 = _a[1];
138
+ obj.scale.x = sizew_1 / myThis_1.svgBoxSize.x;
139
+ obj.scale.y = sizeh_1 / myThis_1.svgBoxSize.y;
71
140
  obj.scale.z = obj.scale.x;
141
+ if (myThis_1.svgReverse) {
142
+ obj.scale.y *= -1;
143
+ }
144
+ obj.rotateZ(myThis_1.svgRotate);
72
145
  myThis_1.isSvgDirtyLocation = true;
73
- var color_1 = new THREE.Color(_this.color);
146
+ var color_1 = new THREE.Color(pWorldDraw.getColor());
74
147
  obj.traverse(function (child) {
75
148
  if (child.material) {
76
149
  child.material = child.material.clone();
77
150
  child.material.transparent = true;
78
- child.material.color = color_1;
151
+ if (!myThis_1.useSvgColor)
152
+ child.material.color = color_1;
79
153
  }
80
154
  });
81
155
  //this.svgPos.multiply
82
156
  myThis_1.svg = obj;
83
- myThis_1.setNeedUpdateDisplay(true);
84
- MxFun_1.default.updateDisplay();
157
+ myThis_1.setNeedUpdateDisplay();
158
+ mxobj_1.updateDisplay();
85
159
  }
86
160
  myThis_1.isLoadFromPath = false;
87
161
  });
88
162
  }
89
163
  }
90
- pWorldDraw.drawSelectLine(pt1.x, pt1.y, pt2.x, pt2.y);
91
- pWorldDraw.drawSelectLine(pt1.x, pt2.y, pt2.x, pt1.y);
164
+ pWorldDraw.drawSelectLine(pt1, pt2);
165
+ pWorldDraw.drawSelectLine(pt3, pt4);
92
166
  }
93
167
  else {
94
- pWorldDraw.drawLine(pt1.x, pt1.y, pt1.x, pt2.y);
95
- pWorldDraw.drawLine(pt1.x, pt2.y, pt2.x, pt2.y);
96
- pWorldDraw.drawLine(pt2.x, pt2.y, pt2.x, pt1.y);
97
- pWorldDraw.drawLine(pt2.x, pt1.y, pt1.x, pt1.y);
168
+ pWorldDraw.drawLine(pt1, pt3);
169
+ pWorldDraw.drawLine(pt3, pt2);
170
+ pWorldDraw.drawLine(pt2, pt4);
171
+ pWorldDraw.drawLine(pt4, pt1);
98
172
  }
99
173
  };
100
174
  MxDbSVG.prototype.setSvgPath = function (path) {
101
175
  this.svgPath = path;
102
176
  this.svg = null;
103
177
  this.isLoadFromPath = true;
178
+ this.svgBoxSize = null;
104
179
  };
105
180
  MxDbSVG.prototype.getSvgPath = function () {
106
181
  return this.svgPath;
107
182
  };
108
183
  MxDbSVG.prototype.setSvgPostion = function (pos) {
109
- this.svgPos = pos;
184
+ this.svgPos = pos.clone();
110
185
  this.isSvgDirtyLocation = true;
111
186
  };
112
187
  MxDbSVG.prototype.getSvgPostion = function () {
@@ -145,25 +220,35 @@ var MxDbSVG = /** @class */ (function (_super) {
145
220
  MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
146
221
  if (index == 0) {
147
222
  this.svgPos.add(offset);
148
- this.aryText.forEach(function (txt) {
149
- txt.txtPos.add(offset);
150
- });
223
+ if (!this.fixedSize) {
224
+ this.aryText.forEach(function (txt) {
225
+ txt.txtPos.add(offset);
226
+ });
227
+ }
151
228
  }
152
229
  this.isSvgDirtyLocation = true;
153
230
  return true;
154
231
  };
155
- MxDbSVG.prototype.calcSvgPosition = function () {
232
+ MxDbSVG.prototype.calcSvgPosition = function (mxObj) {
156
233
  if (!this.svg || !this.isSvgDirtyLocation) {
157
234
  return;
158
235
  }
159
236
  this.isSvgDirtyLocation = false;
160
- this.svg.position.x = this.svgPos.x - this.svgSize.x * this.svgAlignmentRatio.x;
161
- this.svg.position.y = this.svgPos.y - this.svgSize.y * this.svgAlignmentRatio.y;
237
+ var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
238
+ this.svg.position.x =
239
+ this.svgPos.x - sizew * this.svgAlignmentRatio.x - this.svgMargin.x * sizew;
240
+ this.svg.position.y =
241
+ this.svgPos.y - sizeh * this.svgAlignmentRatio.y - this.svgMargin.y * sizeh;
162
242
  };
163
243
  MxDbSVG.prototype.dwgIn = function (obj) {
164
244
  var _this = this;
165
245
  this.onDwgIn(obj);
166
- if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
246
+ this.fixedSize = obj['fixedSize'];
247
+ if (this.fixedSize) {
248
+ // svg = null,重新加载svg.
249
+ this.svg = null;
250
+ }
251
+ else if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
167
252
  this.svg = obj['svg'].clone();
168
253
  }
169
254
  this.svgPos.copy(obj['svgPos']);
@@ -173,6 +258,7 @@ var MxDbSVG = /** @class */ (function (_super) {
173
258
  this.isSvgDirtyLocation = true;
174
259
  if (!this.svg)
175
260
  this.isLoadFromPath = true;
261
+ this.svgBoxSize = null;
176
262
  var aryText = obj['txts'];
177
263
  this.aryText = [];
178
264
  aryText.forEach(function (txt) {
@@ -182,6 +268,10 @@ var MxDbSVG = /** @class */ (function (_super) {
182
268
  copyTxt.txtPos.copy(txt.txtPos);
183
269
  _this.aryText.push(copyTxt);
184
270
  });
271
+ this.svgRotate = obj['svgRotate'];
272
+ this.useSvgColor = obj['useSvgColor'];
273
+ this.svgReverse = obj['svgReverse'];
274
+ this.svgMargin = obj['svgMargin'];
185
275
  return true;
186
276
  };
187
277
  MxDbSVG.prototype.dwgOut = function (obj) {
@@ -194,6 +284,11 @@ var MxDbSVG = /** @class */ (function (_super) {
194
284
  obj['svgSize'] = this.svgSize;
195
285
  obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
196
286
  obj['txts'] = this.aryText;
287
+ obj['fixedSize'] = this.fixedSize;
288
+ obj['svgRotate'] = this.svgRotate;
289
+ obj['useSvgColor'] = this.useSvgColor;
290
+ obj['svgReverse'] = this.svgReverse;
291
+ obj['svgMargin'] = this.svgMargin;
197
292
  return obj;
198
293
  };
199
294
  MxDbSVG.prototype.create = function () {
@@ -202,9 +297,11 @@ var MxDbSVG = /** @class */ (function (_super) {
202
297
  MxDbSVG.prototype.transformBy = function (mat) {
203
298
  this.svgPos.applyMatrix4(mat);
204
299
  this.isSvgDirtyLocation = true;
205
- this.aryText.forEach(function (txt) {
206
- txt.txtPos.applyMatrix4(mat);
207
- });
300
+ if (!this.fixedSize) {
301
+ this.aryText.forEach(function (txt) {
302
+ txt.txtPos.applyMatrix4(mat);
303
+ });
304
+ }
208
305
  };
209
306
  MxDbSVG.prototype.getTypeName = function () {
210
307
  return 'MxDbSVG';
@@ -220,6 +317,53 @@ var MxDbSVG = /** @class */ (function (_super) {
220
317
  });
221
318
  }
222
319
  };
320
+ MxDbSVG.prototype.onViewChange = function () {
321
+ if (!this.fixedSize) {
322
+ return false;
323
+ }
324
+ var mxObj = this.getMxObject();
325
+ if (mxObj == null)
326
+ return false;
327
+ if (this.svg) {
328
+ if (!this.svgBoxSize) {
329
+ this.svgBoxSize = new THREE.Vector3();
330
+ var box = new THREE.Box3().setFromObject(this.svg);
331
+ this.svgBoxSize.x = box.max.x - box.min.x;
332
+ this.svgBoxSize.y = box.max.y - box.min.y;
333
+ }
334
+ var _a = this.calcVewSize(mxObj), sizew = _a[0], sizeh = _a[1];
335
+ this.svg.scale.x = sizew / this.svgBoxSize.x;
336
+ this.svg.scale.y = sizeh / this.svgBoxSize.y;
337
+ this.svg.scale.z = this.svg.scale.x;
338
+ if (this.svgReverse) {
339
+ this.svg.scale.y *= -1;
340
+ }
341
+ this.isSvgDirtyLocation = true;
342
+ this.calcSvgPosition(mxObj);
343
+ }
344
+ var myThis = this;
345
+ this.aryText.forEach(function (txt) {
346
+ if (txt._txtObject && mxObj) {
347
+ var iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
348
+ if (iSize > 0.00001) {
349
+ if (txt._txtAspectRatio <= 0) {
350
+ txt._txtAspectRatio = txt._txtObject.scale.x / txt._txtObject.scale.y;
351
+ }
352
+ txt._txtObject.scale.set(txt._txtAspectRatio * iSize, iSize, 1);
353
+ if (txt.txtPos.x > 0)
354
+ txt._txtObject.position.x = myThis.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
355
+ else
356
+ txt._txtObject.position.x = myThis.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
357
+ if (txt.txtPos.y > 0)
358
+ txt._txtObject.position.y = myThis.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
359
+ else
360
+ txt._txtObject.position.y = myThis.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
361
+ txt._txtObject.updateMatrix();
362
+ }
363
+ }
364
+ });
365
+ return true;
366
+ };
223
367
  return MxDbSVG;
224
368
  }(MxDbEntity_1.default));
225
369
  exports.default = MxDbSVG;
@@ -12,6 +12,9 @@ var MxDbSVGText = /** @class */ (function () {
12
12
  this.txtPos = new THREE.Vector3();
13
13
  this.txt = '';
14
14
  this.txtHeight = 1;
15
+ this.color = undefined;
16
+ this._txtObject = null;
17
+ this._txtAspectRatio = -1;
15
18
  }
16
19
  return MxDbSVGText;
17
20
  }());
@@ -1,6 +1,43 @@
1
1
  "use strict";
2
2
  /** @module MxDrawObject */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (_) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
3
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
+ var MxThreeJS_1 = require("../MxThreeJS");
4
41
  /**
5
42
  * 引入mxdraw库不会挂载MxDrawObject 只能在以下特定函数中获取
6
43
  * @function
@@ -661,8 +698,30 @@ var MxDrawObject = /** @class */ (function () {
661
698
  *
662
699
  * ```
663
700
  */
664
- MxDrawObject.prototype.loadMxEntityFromJson = function (dataString) {
665
- return this._mxdrawObj.loadMxEntityFromJson(dataString);
701
+ MxDrawObject.prototype.loadMxEntityFromJson = function (dataString, aryPreloadSVG) {
702
+ if (aryPreloadSVG === void 0) { aryPreloadSVG = null; }
703
+ return __awaiter(this, void 0, void 0, function () {
704
+ var iLen, i;
705
+ return __generator(this, function (_a) {
706
+ switch (_a.label) {
707
+ case 0:
708
+ if (!aryPreloadSVG) return [3 /*break*/, 4];
709
+ iLen = aryPreloadSVG.length;
710
+ i = 0;
711
+ _a.label = 1;
712
+ case 1:
713
+ if (!(i < iLen)) return [3 /*break*/, 4];
714
+ return [4 /*yield*/, MxThreeJS_1.default.loadSVG(aryPreloadSVG[i])];
715
+ case 2:
716
+ _a.sent();
717
+ _a.label = 3;
718
+ case 3:
719
+ i++;
720
+ return [3 /*break*/, 1];
721
+ case 4: return [2 /*return*/, this._mxdrawObj.loadMxEntityFromJson(dataString)];
722
+ }
723
+ });
724
+ });
666
725
  };
667
726
  /**
668
727
  * 删除所有对MxEntity
@@ -677,6 +736,19 @@ var MxDrawObject = /** @class */ (function () {
677
736
  MxDrawObject.prototype.eraseAllMxEntity = function () {
678
737
  return this._mxdrawObj.eraseAllMxEntity();
679
738
  };
739
+ /**
740
+ * 把该控件对象,设置成当前控件.
741
+ * @param
742
+ * @returns
743
+ * @example
744
+ * ```typescript
745
+ *
746
+ *
747
+ * ```
748
+ */
749
+ MxDrawObject.prototype.makeCurrent = function () {
750
+ this._mxdrawObj.makeCurrent();
751
+ };
680
752
  return MxDrawObject;
681
753
  }());
682
754
  exports.default = MxDrawObject;
@@ -15,6 +15,7 @@ var proxy_1 = require("../../tools/proxy");
15
15
  var MxDrawObject_1 = require("../MxDrawObject");
16
16
  var store_1 = require("../store/store");
17
17
  var useCanvasResizeListener_1 = require("../useCanvasResizeListener");
18
+ var MrxDbgUiPrPoint_1 = require("../MrxDbgUiPrPoint");
18
19
  /**
19
20
  * MxFun 模块
20
21
  * 导出库时已实例化,只需要调用实例方法 例如:
@@ -560,8 +561,9 @@ var MxFun = /** @class */ (function () {
560
561
  * ``` typescript
561
562
  * ```
562
563
  */
563
- MxFun.prototype.openFile = function (sFile) {
564
- return store_1.default.state.MxFun.openFile(sFile);
564
+ MxFun.prototype.openFile = function (sFile, useWebsocket) {
565
+ if (useWebsocket === void 0) { useWebsocket = false; }
566
+ return store_1.default.state.MxFun.openFile(sFile, useWebsocket);
565
567
  };
566
568
  /**
567
569
  * 添加一个MxDbEntity实体到当前绘图对象上。
@@ -576,6 +578,53 @@ var MxFun = /** @class */ (function () {
576
578
  MxFun.prototype.addToCurrentSpace = function (ent) {
577
579
  return this.getCurrentDraw().addMxEntity(ent);
578
580
  };
581
+ /**
582
+ * 在图上选择一个对象。
583
+ * @param strPrompt 提示字符串
584
+ * @param filter 过滤条件
585
+ * @returns number 返回对象的id
586
+ * @example
587
+ * ```typescript
588
+ *
589
+ *
590
+ * ```
591
+ */
592
+ MxFun.prototype.selectEnt = function (strPrompt, filter) {
593
+ var _this = this;
594
+ if (filter === void 0) { filter = null; }
595
+ return new Promise(function (resolve, reject) {
596
+ var getPoint = new MrxDbgUiPrPoint_1.default();
597
+ getPoint.setMessage(strPrompt);
598
+ getPoint.go(function (status) {
599
+ if (status != 0) {
600
+ resolve(0);
601
+ return;
602
+ }
603
+ var pt = getPoint.value();
604
+ var mxobj = _this.getCurrentDraw();
605
+ var aryFind = mxobj.findMxEntityAtPoint(pt);
606
+ var iFindId = 0;
607
+ while (true) {
608
+ if (aryFind.length == 0) {
609
+ break;
610
+ }
611
+ var iLen = aryFind.length;
612
+ for (var i = 0; i < iLen; i++) {
613
+ var ent = aryFind[i];
614
+ if (filter) {
615
+ if (filter['type'] && filter['type'] != ent.getTypeName()) {
616
+ continue;
617
+ }
618
+ }
619
+ iFindId = ent.objectId();
620
+ break;
621
+ }
622
+ break;
623
+ }
624
+ resolve(iFindId);
625
+ });
626
+ });
627
+ };
579
628
  return MxFun;
580
629
  }());
581
630
  exports.default = MxFun;
@@ -273,7 +273,11 @@ var MxThreeJS = /** @class */ (function () {
273
273
  * })
274
274
  * ```
275
275
  */
276
- MxThreeJS.prototype.loadSVG = function (url, color, callResult) { };
276
+ MxThreeJS.prototype.loadSVG = function (url, color, callResult) {
277
+ return new Promise(function (resolve) {
278
+ resolve(null);
279
+ });
280
+ };
277
281
  return MxThreeJS;
278
282
  }());
279
283
  exports.default = MxThreeJS;
@@ -21,10 +21,10 @@ var MxThreeJSBuffer = /** @class */ (function () {
21
21
  var aryMeterial = [];
22
22
  var paths = data.paths;
23
23
  var group = new three_1.Group();
24
- var drawStrokes = true;
25
- var strokesWireframe = false;
24
+ var drawStrokes = false;
26
25
  var drawFillShapes = true;
27
26
  var fillShapesWireframe = false;
27
+ var strokesWireframe = false;
28
28
  for (var i = 0; i < paths.length; i++) {
29
29
  var path = paths[i];
30
30
  var fillColor = path.userData.style.fill;
@@ -128,7 +128,19 @@ function default_1(MxThreeJS) {
128
128
  });
129
129
  };
130
130
  MxThreeJS.loadSVG = function (url, color, callResult) {
131
- mxThreeJsBuffer.loadSVG(url, color, callResult);
131
+ if (callResult) {
132
+ mxThreeJsBuffer.loadSVG(url, color, callResult);
133
+ return new Promise(function (resolve) {
134
+ resolve(null);
135
+ });
136
+ }
137
+ else {
138
+ return new Promise(function (resolve) {
139
+ mxThreeJsBuffer.loadSVG(url, color, function (threeobj) {
140
+ resolve(threeobj);
141
+ });
142
+ });
143
+ }
132
144
  };
133
145
  }
134
146
  exports.default = default_1;
@@ -41,17 +41,16 @@ 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
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
- var MxDbLine_1 = require("../MxDbLine");
48
- var MxDbRect_1 = require("../MxDbRect");
49
44
  function rxInitMxEntity() {
50
- new MxDbImage_1.default().rxInit();
51
- new MxDbSVG_1.default().rxInit();
52
- new MxDbAlignedDimension_1.default().rxInit();
53
- new MxDbLine_1.default().rxInit();
54
- new MxDbRect_1.default().rxInit();
45
+ /*
46
+ new MxDbImage().rxInit()
47
+ new MxDbSVG().rxInit()
48
+ new MxDbAlignedDimension().rxInit()
49
+ new MxDbLine().rxInit()
50
+ new MxDbRect().rxInit()
51
+ */
52
+ ;
53
+ store_1.default.state.MxFun.initDynamicCreate(dynamicImport_1.dynamicCreateMxObject);
55
54
  }
56
55
  /**
57
56
  * 加载MxDraw库的核心代码 才能使用Mx的其他模块