mxdraw 0.1.8 → 0.1.11

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 (35) hide show
  1. package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +53 -12
  2. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +2 -1
  3. package/dist/lib/MxModule/MxDbRect/MxDbRect.js +140 -86
  4. package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +194 -58
  5. package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +21 -0
  6. package/dist/lib/MxModule/MxDbSVGText/index.js +5 -0
  7. package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +74 -2
  8. package/dist/lib/MxModule/MxFun/MxFun.js +64 -2
  9. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +5 -1
  10. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +13 -1
  11. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +9 -8
  12. package/dist/lib/MxModule/loadCoreCode/mxUiData.js +317 -0
  13. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +196 -64
  14. package/dist/lib/mxdraw.js +4 -1
  15. package/dist/lib/tools/dynamicImport/index.js +45 -1
  16. package/dist/lib/tools/three/index.js +21 -15
  17. package/dist/mxdraw.es5.js +3 -3
  18. package/dist/mxdraw.es5.js.map +1 -1
  19. package/dist/mxdraw.umd.js +3 -3
  20. package/dist/mxdraw.umd.js.map +1 -1
  21. package/dist/types/MxModule/McGiWorldDraw/McGiWorldDraw.d.ts +1 -1
  22. package/dist/types/MxModule/MxDbEntity/MxDbEntity.d.ts +33 -4
  23. package/dist/types/MxModule/MxDbRect/MxDbRect.d.ts +21 -42
  24. package/dist/types/MxModule/MxDbSVG/MxDbSVG.d.ts +10 -9
  25. package/dist/types/MxModule/MxDbSVGText/MxDbSVGText.d.ts +10 -0
  26. package/dist/types/MxModule/MxDbSVGText/index.d.ts +3 -0
  27. package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +12 -1
  28. package/dist/types/MxModule/MxFun/MxFun.d.ts +25 -1
  29. package/dist/types/MxModule/MxThreeJS/MxThreeJS.d.ts +1 -1
  30. package/dist/types/MxModule/loadCoreCode/mxUiData.d.ts +111 -0
  31. package/dist/types/mxdraw.d.ts +3 -1
  32. package/dist/types/tools/dynamicImport/index.d.ts +1 -0
  33. package/dist/types/types/MxDrawObject.d.ts +2 -1
  34. package/dist/types/types/MxFun.d.ts +2 -1
  35. package/package.json +1 -1
@@ -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,9 +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
- var MxFun_1 = require("../MxFun");
26
+ var MxDbSVGText_1 = require("../MxDbSVGText");
27
27
  var MxThreeJS_1 = require("../MxThreeJS");
28
28
  var MxType_1 = require("../MxType");
29
29
  /**
@@ -34,74 +34,132 @@ var MxDbSVG = /** @class */ (function (_super) {
34
34
  function MxDbSVG() {
35
35
  var _this = _super !== null && _super.apply(this, arguments) || this;
36
36
  _this.svgPos = new THREE.Vector3();
37
+ _this.svg = null;
37
38
  _this.svgPath = '';
38
39
  _this.svgSize = new THREE.Vector2(50, 50);
39
40
  _this.svgAlignmentRatio = new THREE.Vector2(0, 0);
41
+ _this.svgRotate = 0;
40
42
  _this.isSvgDirtyLocation = false;
41
43
  _this.isLoadFromPath = true;
42
- _this.txtPos = new THREE.Vector3();
43
- _this.txt = '';
44
- _this.txtHeight = 1;
44
+ _this.aryText = [];
45
+ _this.svgBoxSize = null;
46
+ // 固定尺寸,图片和文字大小,取屏幕像素绘图单位。
47
+ _this.fixedSize = false;
48
+ _this.useSvgColor = false;
45
49
  return _this;
46
50
  }
47
51
  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
+ var _this = this;
53
+ var mxObj = pWorldDraw.getMxObject();
54
+ this.calcSvgPosition(mxObj);
55
+ var sizew = this.svgSize.x;
56
+ var sizeh = this.svgSize.y;
57
+ if (this.fixedSize) {
58
+ sizew = mxObj.screenCoordLong2Doc(sizew);
59
+ sizeh = mxObj.screenCoordLong2Doc(sizeh);
52
60
  }
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);
61
+ var mat = new THREE.Matrix4();
62
+ mat.makeRotationZ(this.svgRotate);
63
+ var matMove = new THREE.Matrix4();
64
+ var svgNewPos = new THREE.Vector3(this.svgPos.x - sizew * this.svgAlignmentRatio.x, this.svgPos.y - sizeh * this.svgAlignmentRatio.y, 0);
65
+ matMove.makeTranslation(svgNewPos.x, svgNewPos.y, svgNewPos.z);
66
+ mat.premultiply(matMove);
67
+ var pt1 = new THREE.Vector3(0, 0, 0);
68
+ var pt3 = new THREE.Vector3(sizew, 0, 0);
69
+ var pt2 = new THREE.Vector3(sizew, sizeh, 0);
70
+ var pt4 = new THREE.Vector3(0, sizeh, 0);
71
+ pt1.applyMatrix4(mat);
72
+ pt3.applyMatrix4(mat);
73
+ pt2.applyMatrix4(mat);
74
+ pt4.applyMatrix4(mat);
57
75
  if (pWorldDraw.getType() == 1) {
76
+ this.aryText.forEach(function (txt) {
77
+ if (txt.txt.length > 0) {
78
+ var posTxt = new THREE.Vector3(txt.txtPos.x, txt.txtPos.y, 0);
79
+ if (_this.fixedSize) {
80
+ if (txt.txtPos.x > 0)
81
+ posTxt.x = _this.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
82
+ else
83
+ posTxt.x = _this.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
84
+ if (txt.txtPos.y > 0)
85
+ posTxt.y = _this.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
86
+ else
87
+ posTxt.y = _this.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
88
+ }
89
+ var bakColor = undefined;
90
+ if (txt.color) {
91
+ bakColor = pWorldDraw.getColor();
92
+ pWorldDraw.setColor(txt.color);
93
+ }
94
+ var iSize = txt.txtHeight;
95
+ if (_this.fixedSize)
96
+ iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
97
+ txt._txtObject = pWorldDraw.drawText(txt.txt, iSize, 0, posTxt);
98
+ txt._txtAspectRatio = -1;
99
+ if (bakColor) {
100
+ pWorldDraw.setColor(bakColor);
101
+ }
102
+ }
103
+ });
58
104
  if (this.svg) {
59
105
  pWorldDraw.drawEntity(this.svg);
60
106
  }
61
107
  else {
62
108
  if (this.svgPath.length > 0 && this.isLoadFromPath) {
63
109
  var myThis_1 = this;
110
+ var mxobj_1 = pWorldDraw.getMxObject();
64
111
  MxThreeJS_1.default.loadSVG(this.svgPath, undefined, function (obj) {
65
112
  if (obj) {
66
113
  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);
114
+ if (!myThis_1.svgBoxSize) {
115
+ myThis_1.svgBoxSize = new THREE.Vector3();
116
+ }
117
+ myThis_1.svgBoxSize.x = box.max.x - box.min.x;
118
+ myThis_1.svgBoxSize.y = box.max.y - box.min.y;
119
+ obj.scale.x = sizew / myThis_1.svgBoxSize.x;
120
+ obj.scale.y = sizeh / myThis_1.svgBoxSize.y;
69
121
  obj.scale.z = obj.scale.x;
122
+ obj.rotateZ(myThis_1.svgRotate);
70
123
  myThis_1.isSvgDirtyLocation = true;
124
+ var color_1 = new THREE.Color(pWorldDraw.getColor());
71
125
  obj.traverse(function (child) {
72
126
  if (child.material) {
127
+ child.material = child.material.clone();
73
128
  child.material.transparent = true;
129
+ if (!myThis_1.useSvgColor)
130
+ child.material.color = color_1;
74
131
  }
75
132
  });
76
133
  //this.svgPos.multiply
77
134
  myThis_1.svg = obj;
78
- myThis_1.setNeedUpdateDisplay(true);
79
- MxFun_1.default.updateDisplay();
135
+ myThis_1.setNeedUpdateDisplay();
136
+ mxobj_1.updateDisplay();
80
137
  }
81
138
  myThis_1.isLoadFromPath = false;
82
139
  });
83
140
  }
84
141
  }
85
- pWorldDraw.drawSelectLine(pt1.x, pt1.y, pt2.x, pt2.y);
86
- pWorldDraw.drawSelectLine(pt1.x, pt2.y, pt2.x, pt1.y);
142
+ pWorldDraw.drawSelectLine(pt1, pt2);
143
+ pWorldDraw.drawSelectLine(pt3, pt4);
87
144
  }
88
145
  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);
146
+ pWorldDraw.drawLine(pt1, pt3);
147
+ pWorldDraw.drawLine(pt3, pt2);
148
+ pWorldDraw.drawLine(pt2, pt4);
149
+ pWorldDraw.drawLine(pt4, pt1);
93
150
  }
94
151
  };
95
152
  MxDbSVG.prototype.setSvgPath = function (path) {
96
153
  this.svgPath = path;
97
154
  this.svg = null;
98
155
  this.isLoadFromPath = true;
156
+ this.svgBoxSize = null;
99
157
  };
100
158
  MxDbSVG.prototype.getSvgPath = function () {
101
159
  return this.svgPath;
102
160
  };
103
161
  MxDbSVG.prototype.setSvgPostion = function (pos) {
104
- this.svgPos = pos;
162
+ this.svgPos = pos.clone();
105
163
  this.isSvgDirtyLocation = true;
106
164
  };
107
165
  MxDbSVG.prototype.getSvgPostion = function () {
@@ -121,24 +179,16 @@ var MxDbSVG = /** @class */ (function (_super) {
121
179
  MxDbSVG.prototype.getSvgAlignmentRatio = function () {
122
180
  return this.svgAlignmentRatio;
123
181
  };
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;
182
+ MxDbSVG.prototype.getText = function (index) {
183
+ if (index < this.aryText.length) {
184
+ return this.aryText[index];
185
+ }
186
+ else {
187
+ return null;
188
+ }
139
189
  };
140
- MxDbSVG.prototype.getTextPostion = function () {
141
- return this.txtPos;
190
+ MxDbSVG.prototype.addText = function (txt) {
191
+ this.aryText.push(txt);
142
192
  };
143
193
  MxDbSVG.prototype.getGripPoints = function () {
144
194
  var ret = [];
@@ -148,22 +198,38 @@ var MxDbSVG = /** @class */ (function (_super) {
148
198
  MxDbSVG.prototype.moveGripPointsAt = function (index, offset) {
149
199
  if (index == 0) {
150
200
  this.svgPos.add(offset);
151
- this.txtPos.add(offset);
201
+ if (!this.fixedSize) {
202
+ this.aryText.forEach(function (txt) {
203
+ txt.txtPos.add(offset);
204
+ });
205
+ }
152
206
  }
153
207
  this.isSvgDirtyLocation = true;
154
208
  return true;
155
209
  };
156
- MxDbSVG.prototype.calcSvgPosition = function () {
210
+ MxDbSVG.prototype.calcSvgPosition = function (mxObj) {
157
211
  if (!this.svg || !this.isSvgDirtyLocation) {
158
212
  return;
159
213
  }
160
214
  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;
215
+ var sizew = this.svgSize.x;
216
+ var sizeh = this.svgSize.y;
217
+ if (this.fixedSize) {
218
+ sizew = mxObj.screenCoordLong2Doc(sizew);
219
+ sizeh = mxObj.screenCoordLong2Doc(sizeh);
220
+ }
221
+ this.svg.position.x = this.svgPos.x - sizew * this.svgAlignmentRatio.x;
222
+ this.svg.position.y = this.svgPos.y - sizeh * this.svgAlignmentRatio.y;
163
223
  };
164
224
  MxDbSVG.prototype.dwgIn = function (obj) {
225
+ var _this = this;
165
226
  this.onDwgIn(obj);
166
- if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
227
+ this.fixedSize = obj['fixedSize'];
228
+ if (this.fixedSize) {
229
+ // svg = null,重新加载svg.
230
+ this.svg = null;
231
+ }
232
+ else if (obj.type == MxType_1.default.MxCloneType.kClone && obj['svg']) {
167
233
  this.svg = obj['svg'].clone();
168
234
  }
169
235
  this.svgPos.copy(obj['svgPos']);
@@ -173,9 +239,18 @@ var MxDbSVG = /** @class */ (function (_super) {
173
239
  this.isSvgDirtyLocation = true;
174
240
  if (!this.svg)
175
241
  this.isLoadFromPath = true;
176
- this.txt = obj['txt'];
177
- this.txtHeight = obj['txtHeight'];
178
- this.txtPos.copy(obj['txtPos']);
242
+ this.svgBoxSize = null;
243
+ var aryText = obj['txts'];
244
+ this.aryText = [];
245
+ aryText.forEach(function (txt) {
246
+ var copyTxt = new MxDbSVGText_1.default();
247
+ copyTxt.txt = txt.txt;
248
+ copyTxt.txtHeight = txt.txtHeight;
249
+ copyTxt.txtPos.copy(txt.txtPos);
250
+ _this.aryText.push(copyTxt);
251
+ });
252
+ this.svgRotate = obj['svgRotate'];
253
+ this.useSvgColor = obj['useSvgColor'];
179
254
  return true;
180
255
  };
181
256
  MxDbSVG.prototype.dwgOut = function (obj) {
@@ -187,9 +262,10 @@ var MxDbSVG = /** @class */ (function (_super) {
187
262
  obj['svgPos'] = this.svgPos;
188
263
  obj['svgSize'] = this.svgSize;
189
264
  obj['svgAlignmentRatio'] = this.svgAlignmentRatio;
190
- obj['txt'] = this.txt;
191
- obj['txtHeight'] = this.txtHeight;
192
- obj['txtPos'] = this.txtPos;
265
+ obj['txts'] = this.aryText;
266
+ obj['fixedSize'] = this.fixedSize;
267
+ obj['svgRotate'] = this.svgRotate;
268
+ obj['useSvgColor'] = this.useSvgColor;
193
269
  return obj;
194
270
  };
195
271
  MxDbSVG.prototype.create = function () {
@@ -197,12 +273,72 @@ var MxDbSVG = /** @class */ (function (_super) {
197
273
  };
198
274
  MxDbSVG.prototype.transformBy = function (mat) {
199
275
  this.svgPos.applyMatrix4(mat);
200
- this.txtPos.applyMatrix4(mat);
201
276
  this.isSvgDirtyLocation = true;
277
+ if (!this.fixedSize) {
278
+ this.aryText.forEach(function (txt) {
279
+ txt.txtPos.applyMatrix4(mat);
280
+ });
281
+ }
202
282
  };
203
283
  MxDbSVG.prototype.getTypeName = function () {
204
284
  return 'MxDbSVG';
205
285
  };
286
+ MxDbSVG.prototype.setColor = function (color) {
287
+ _super.prototype.setColor.call(this, color);
288
+ if (this.svg) {
289
+ var color_2 = new THREE.Color(this.color);
290
+ this.svg.traverse(function (child) {
291
+ if (child.material) {
292
+ child.material.color = color_2;
293
+ }
294
+ });
295
+ }
296
+ };
297
+ MxDbSVG.prototype.onViewChange = function () {
298
+ if (!this.fixedSize) {
299
+ return false;
300
+ }
301
+ var mxObj = this.getMxObject();
302
+ if (mxObj == null)
303
+ return false;
304
+ if (this.svg) {
305
+ if (!this.svgBoxSize) {
306
+ this.svgBoxSize = new THREE.Vector3();
307
+ var box = new THREE.Box3().setFromObject(this.svg);
308
+ this.svgBoxSize.x = box.max.x - box.min.x;
309
+ this.svgBoxSize.y = box.max.y - box.min.y;
310
+ }
311
+ var sizew = mxObj.screenCoordLong2Doc(this.svgSize.x);
312
+ var sizeh = mxObj.screenCoordLong2Doc(this.svgSize.y);
313
+ this.svg.scale.x = sizew / this.svgBoxSize.x;
314
+ this.svg.scale.y = sizeh / this.svgBoxSize.y;
315
+ this.svg.scale.z = this.svg.scale.x;
316
+ this.isSvgDirtyLocation = true;
317
+ this.calcSvgPosition(mxObj);
318
+ }
319
+ var myThis = this;
320
+ this.aryText.forEach(function (txt) {
321
+ if (txt._txtObject && mxObj) {
322
+ var iSize = mxObj.screenCoordLong2Doc(txt.txtHeight);
323
+ if (iSize > 0.00001) {
324
+ if (txt._txtAspectRatio <= 0) {
325
+ txt._txtAspectRatio = txt._txtObject.scale.x / txt._txtObject.scale.y;
326
+ }
327
+ txt._txtObject.scale.set(txt._txtAspectRatio * iSize, iSize, 1);
328
+ if (txt.txtPos.x > 0)
329
+ txt._txtObject.position.x = myThis.svgPos.x + mxObj.screenCoordLong2Doc(txt.txtPos.x);
330
+ else
331
+ txt._txtObject.position.x = myThis.svgPos.x - mxObj.screenCoordLong2Doc(txt.txtPos.x);
332
+ if (txt.txtPos.y > 0)
333
+ txt._txtObject.position.y = myThis.svgPos.y + mxObj.screenCoordLong2Doc(txt.txtPos.y);
334
+ else
335
+ txt._txtObject.position.y = myThis.svgPos.y - mxObj.screenCoordLong2Doc(txt.txtPos.y);
336
+ txt._txtObject.updateMatrix();
337
+ }
338
+ }
339
+ });
340
+ return true;
341
+ };
206
342
  return MxDbSVG;
207
343
  }(MxDbEntity_1.default));
208
344
  exports.default = MxDbSVG;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+ //版权所有(C)2002-2022,成都梦想凯德科技有限公司。
5
+ //本软件代码及其文档和相关资料归成都梦想凯德科技有限公司,应用包含本软件的程序必须包括以下版权声明
6
+ //此应用程序与成都梦想凯德科技有限公司成协议。通过使用本软件、其文档或相关材料
7
+ ///////////////////////////////////////////////////////////////////////////////
8
+ /** @module MxDbSVG*/
9
+ var THREE = require("three");
10
+ var MxDbSVGText = /** @class */ (function () {
11
+ function MxDbSVGText() {
12
+ this.txtPos = new THREE.Vector3();
13
+ this.txt = '';
14
+ this.txtHeight = 1;
15
+ this.color = undefined;
16
+ this._txtObject = null;
17
+ this._txtAspectRatio = -1;
18
+ }
19
+ return MxDbSVGText;
20
+ }());
21
+ exports.default = MxDbSVGText;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /** @module McEdGetPointWorldDrawObject*/
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var MxDbSVGText_1 = require("./MxDbSVGText");
5
+ exports.default = MxDbSVGText_1.default;
@@ -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,69 @@ 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);
567
+ };
568
+ /**
569
+ * 添加一个MxDbEntity实体到当前绘图对象上。
570
+ * @param ent 实体对象
571
+ * @returns number 返回对象的id.
572
+ * @example
573
+ * ```typescript
574
+ *
575
+ *
576
+ * ```
577
+ */
578
+ MxFun.prototype.addToCurrentSpace = function (ent) {
579
+ return this.getCurrentDraw().addMxEntity(ent);
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
+ });
565
627
  };
566
628
  return MxFun;
567
629
  }());
@@ -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;
@@ -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,15 +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
44
  function rxInitMxEntity() {
49
- new MxDbImage_1.default().rxInit();
50
- new MxDbSVG_1.default().rxInit();
51
- new MxDbAlignedDimension_1.default().rxInit();
52
- new MxDbLine_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);
53
54
  }
54
55
  /**
55
56
  * 加载MxDraw库的核心代码 才能使用Mx的其他模块