mxdraw 0.1.21 → 0.1.25

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 (120) hide show
  1. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.js +1 -128
  2. package/dist/lib/MxModule/McEdGetPointWorldDrawObject/index.js +1 -5
  3. package/dist/lib/MxModule/McGePoint3d/McGePoint3d.js +1 -0
  4. package/dist/lib/MxModule/McGePoint3d/index.js +1 -0
  5. package/dist/lib/MxModule/McGePoint3dArray/McGePoint3dArray.js +1 -0
  6. package/dist/lib/MxModule/McGePoint3dArray/index.js +1 -0
  7. package/dist/lib/MxModule/McGeTool/McGeTool.js +1 -0
  8. package/dist/lib/MxModule/McGeTool/index.js +1 -0
  9. package/dist/lib/MxModule/McGiWorldDraw/McGiWorldDraw.js +1 -3
  10. package/dist/lib/MxModule/McGiWorldDraw/index.js +1 -2
  11. package/dist/lib/MxModule/McGiWorldDrawType/McGiWorldDrawType.js +1 -19
  12. package/dist/lib/MxModule/McGiWorldDrawType/index.js +1 -4
  13. package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/MrxDbgUiPrBaseReturn.js +1 -31
  14. package/dist/lib/MxModule/MrxDbgUiPrBaseReturn/index.js +1 -5
  15. package/dist/lib/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.js +1 -159
  16. package/dist/lib/MxModule/MrxDbgUiPrPoint/index.js +1 -5
  17. package/dist/lib/MxModule/Mx3PointArc/Mx3PointArc.js +1 -0
  18. package/dist/lib/MxModule/Mx3PointArc/index.js +1 -0
  19. package/dist/lib/MxModule/MxDb2LineAngularDimension/MxDb2LineAngularDimension.js +1 -0
  20. package/dist/lib/MxModule/MxDb2LineAngularDimension/index.js +1 -0
  21. package/dist/lib/MxModule/MxDbAlignedDimension/MxDbAlignedDimension.js +1 -213
  22. package/dist/lib/MxModule/MxDbAlignedDimension/index.js +1 -5
  23. package/dist/lib/MxModule/MxDbAnyLine/MxDbAnyLine.js +1 -0
  24. package/dist/lib/MxModule/MxDbAnyLine/index.js +1 -0
  25. package/dist/lib/MxModule/MxDbArea/MxDbArea.js +1 -0
  26. package/dist/lib/MxModule/MxDbArea/index.js +1 -0
  27. package/dist/lib/MxModule/MxDbCoord/MxDbCoord.js +1 -0
  28. package/dist/lib/MxModule/MxDbCoord/index.js +1 -0
  29. package/dist/lib/MxModule/MxDbEntity/MxDbEntity.js +1 -258
  30. package/dist/lib/MxModule/MxDbEntity/index.js +1 -5
  31. package/dist/lib/MxModule/MxDbImage/MxDbImage.js +1 -160
  32. package/dist/lib/MxModule/MxDbImage/index.js +1 -5
  33. package/dist/lib/MxModule/MxDbLine/MxDbLine.js +1 -94
  34. package/dist/lib/MxModule/MxDbLine/index.js +1 -5
  35. package/dist/lib/MxModule/MxDbPolyline/MxDbPolyline.js +1 -97
  36. package/dist/lib/MxModule/MxDbPolyline/index.js +1 -5
  37. package/dist/lib/MxModule/MxDbRect/MxDbRect.js +1 -273
  38. package/dist/lib/MxModule/MxDbRect/index.js +1 -4
  39. package/dist/lib/MxModule/MxDbSVG/MxDbSVG.js +1 -419
  40. package/dist/lib/MxModule/MxDbSVG/index.js +1 -5
  41. package/dist/lib/MxModule/MxDbSVGText/MxDbSVGText.js +1 -21
  42. package/dist/lib/MxModule/MxDbSVGText/index.js +1 -5
  43. package/dist/lib/MxModule/MxDrawObject/MxDrawObject.js +1 -782
  44. package/dist/lib/MxModule/MxDrawObject/index.js +1 -5
  45. package/dist/lib/MxModule/MxFilters/MxFilters.js +1 -201
  46. package/dist/lib/MxModule/MxFilters/index.js +1 -4
  47. package/dist/lib/MxModule/MxFun/MxFun.js +1 -676
  48. package/dist/lib/MxModule/MxFun/index.js +1 -4
  49. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.js +1 -283
  50. package/dist/lib/MxModule/MxThreeJS/MxThreeJS.mixin.js +1 -146
  51. package/dist/lib/MxModule/MxThreeJS/index.js +1 -7
  52. package/dist/lib/MxModule/MxType/MxType.js +1 -27
  53. package/dist/lib/MxModule/MxType/index.js +1 -4
  54. package/dist/lib/MxModule/Mxassembly/Mxassembly.js +1 -20
  55. package/dist/lib/MxModule/Mxassembly/index.js +1 -9
  56. package/dist/lib/MxModule/loadCoreCode/index.js +1 -5
  57. package/dist/lib/MxModule/loadCoreCode/loadCoreCode.js +1 -125
  58. package/dist/lib/MxModule/loadCoreCode/mxUiData.js +1 -312
  59. package/dist/lib/MxModule/loadCoreCode/mxcadassembly_es5.js +1 -1519
  60. package/dist/lib/MxModule/loadCoreCode/mxfun.es5.js +1 -7363
  61. package/dist/lib/MxModule/store/PubsubClass.js +1 -40
  62. package/dist/lib/MxModule/store/StoreClass.js +1 -73
  63. package/dist/lib/MxModule/store/index.js +1 -19
  64. package/dist/lib/MxModule/store/store.js +1 -25
  65. package/dist/lib/MxModule/useCanvasResizeListener/index.js +1 -5
  66. package/dist/lib/MxModule/useCanvasResizeListener/useCanvasResizeListener.js +1 -95
  67. package/dist/lib/doc.js +1 -38
  68. package/dist/lib/mxdraw.js +1 -67
  69. package/dist/lib/tools/algorithm/math.js +1 -16
  70. package/dist/lib/tools/algorithm/random.js +1 -13
  71. package/dist/lib/tools/dom/create.js +1 -47
  72. package/dist/lib/tools/dynamicImport/index.js +1 -243
  73. package/dist/lib/tools/formatting/index.js +1 -20
  74. package/dist/lib/tools/proxy/index.js +1 -17
  75. package/dist/lib/tools/three/index.js +1 -124
  76. package/dist/mxdraw.es5.js +1 -0
  77. package/dist/mxdraw.umd.js +1 -0
  78. package/dist/types/MxModule/McEdGetPointWorldDrawObject/McEdGetPointWorldDrawObjectClass.d.ts +9 -0
  79. package/dist/types/MxModule/McGePoint3d/McGePoint3d.d.ts +11 -0
  80. package/dist/types/MxModule/McGePoint3d/index.d.ts +3 -0
  81. package/dist/types/MxModule/McGePoint3dArray/McGePoint3dArray.d.ts +14 -0
  82. package/dist/types/MxModule/McGePoint3dArray/index.d.ts +3 -0
  83. package/dist/types/MxModule/McGeTool/McGeTool.d.ts +38 -0
  84. package/dist/types/MxModule/McGeTool/index.d.ts +4 -0
  85. package/dist/types/MxModule/MrxDbgUiPrPoint/MrxDbgUiPrPointClass.d.ts +18 -1
  86. package/dist/types/MxModule/Mx3PointArc/Mx3PointArc.d.ts +19 -0
  87. package/dist/types/MxModule/Mx3PointArc/index.d.ts +3 -0
  88. package/dist/types/MxModule/MxDb2LineAngularDimension/MxDb2LineAngularDimension.d.ts +22 -0
  89. package/dist/types/MxModule/MxDb2LineAngularDimension/index.d.ts +3 -0
  90. package/dist/types/MxModule/MxDbAnyLine/MxDbAnyLine.d.ts +18 -0
  91. package/dist/types/MxModule/MxDbAnyLine/index.d.ts +3 -0
  92. package/dist/types/MxModule/MxDbArea/MxDbArea.d.ts +17 -0
  93. package/dist/types/MxModule/MxDbArea/index.d.ts +3 -0
  94. package/dist/types/MxModule/MxDbCoord/MxDbCoord.d.ts +19 -0
  95. package/dist/types/MxModule/MxDbCoord/index.d.ts +3 -0
  96. package/dist/types/MxModule/MxDrawObject/MxDrawObject.d.ts +70 -1
  97. package/dist/types/MxModule/MxFun/MxFun.d.ts +95 -30
  98. package/dist/types/MxModule/Mxassembly/Mxassembly.d.ts +11 -2
  99. package/dist/types/MxModule/store/store.d.ts +2 -2
  100. package/dist/types/mxdraw.d.ts +17 -4
  101. package/dist/types/tools/three/index.d.ts +28 -1
  102. package/package.json +3 -2
  103. package/dist/lib/MxModule/McGeVector3d/McGeVector3d.js +0 -2
  104. package/dist/lib/MxModule/McGeVector3d/index.js +0 -3
  105. package/dist/lib/MxModule/MxThreeJS/SVGLoader.js +0 -1862
  106. package/dist/lib/types/McEdGetPointWorldDrawObject.js +0 -2
  107. package/dist/lib/types/MrxDbgUiPrPoint.js +0 -2
  108. package/dist/lib/types/MxCADObject.js +0 -2
  109. package/dist/lib/types/MxDrawObject.js +0 -2
  110. package/dist/lib/types/MxFun.js +0 -2
  111. package/dist/lib/types/Mxassembly.js +0 -2
  112. package/dist/types/MxModule/McGeVector3d/McGeVector3d.d.ts +0 -17
  113. package/dist/types/MxModule/McGeVector3d/index.d.ts +0 -3
  114. package/dist/types/MxModule/MxThreeJS/SVGLoader.d.ts +0 -22
  115. package/dist/types/types/McEdGetPointWorldDrawObject.d.ts +0 -9
  116. package/dist/types/types/MrxDbgUiPrPoint.d.ts +0 -23
  117. package/dist/types/types/MxCADObject.d.ts +0 -40
  118. package/dist/types/types/MxDrawObject.d.ts +0 -60
  119. package/dist/types/types/MxFun.d.ts +0 -47
  120. package/dist/types/types/Mxassembly.d.ts +0 -3
@@ -1,676 +1 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- var random_1 = require("../../tools/algorithm/random");
13
- var create_1 = require("../../tools/dom/create");
14
- var MxDrawObject_1 = require("../MxDrawObject");
15
- var store_1 = require("../store");
16
- var useCanvasResizeListener_1 = require("../useCanvasResizeListener");
17
- var MrxDbgUiPrPoint_1 = require("../MrxDbgUiPrPoint");
18
- var mxUiData_1 = require("../loadCoreCode/mxUiData");
19
- /**
20
- * MxFun 模块
21
- * 导出库时已实例化,只需要调用实例方法 例如:
22
- * ```typescript
23
- * Mx.MxFun.createMxObject
24
- * ```
25
- */
26
- var MxFun = /** @class */ (function () {
27
- function MxFun() {
28
- // 对象方法代理
29
- // objectMethodProxy(this, store.state.MxFun as MxFunType, 'acutPrintf')
30
- }
31
- /**
32
- * 创建图纸展示控件实例
33
- * @param canvasId 提供一个canvas元素或者唯一的ID或者class类亦或者Jquery选中的元素
34
- * @paramType string | HTMLCanvasElement | JQuery<HTMLElement>
35
- * @param cadFile 提供要展示的图纸名称
36
- * @paramType string
37
- * @param callback 图纸展示控件创建完成后的回调函数 回调参数mxDraw和dom
38
- * @paramType function
39
- * @param isNewFile 是否新建文件
40
- * @paramType boolean
41
- * @return void
42
- * @example
43
- * ``` typescript
44
- * Mx.MxFun.createMxObject({
45
- * canvasId: "my-app",
46
- * cadFile: "test2.dwg",
47
- * callback(mxDraw, { canvas, canvasParent }) {
48
- * console.log(mxDraw, canvas, canvasParent)
49
- * },
50
- * isNewFile: true
51
- * })
52
- * ```
53
- */
54
- MxFun.prototype.createMxObject = function (_a) {
55
- 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 ? false : _d, _e = _a.useWebsocket, useWebsocket = _e === void 0 ? false : _e, _f = _a.isAutoResize, isAutoResize = _f === void 0 ? true : _f;
56
- this.initUiDataObject(mxUiData_1.default);
57
- // 获取canvas和其父级
58
- var canvas = (0, create_1.createCanvas)(canvasId);
59
- var canvasParent = (0, create_1.createCanvasParent)(canvas);
60
- if (!canvasParent.parentNode || canvasParent.parentNode.nodeType == 11) {
61
- // canvasParent 未插入到文档
62
- document.body.appendChild(canvasParent);
63
- }
64
- if (!useWebsocket && isNewFile) {
65
- // 只有sockec方式,才能新建文件,这里暂是把isNewFile设置成 false
66
- isNewFile = false;
67
- }
68
- // 设置样式
69
- // canvasParent.style.width = '100%'
70
- // canvasParent.style.height = '80vh'
71
- // canvasParent.style.position = 'relative';
72
- // 创建实例
73
- ;
74
- store_1.default.state.MxFun.createMxObject(canvasId, cadFile, function (mxDraw) {
75
- var mxdrawObj = new MxDrawObject_1.default(mxDraw);
76
- mxDraw.setMouseRightRotate(false);
77
- mxDraw.setIniset({ EnableOsnapFunction: true });
78
- mxDraw.addEvent('onResize', function () {
79
- canvasParent.tabindex = 3;
80
- return {
81
- width: canvasParent.clientWidth,
82
- height: canvasParent.clientHeight
83
- };
84
- });
85
- // 使用canvas侦听器 监听canvas元素的大小变化
86
- if (isAutoResize)
87
- (0, useCanvasResizeListener_1.default)(mxdrawObj, canvas);
88
- callback &&
89
- callback(mxdrawObj, {
90
- canvas: canvas,
91
- canvasParent: canvasParent
92
- });
93
- }, undefined, isNewFile, useWebsocket);
94
- };
95
- /**
96
- * 为程序设置服务器地址
97
- * @param MXSERVER 服务器地址
98
- * @return void
99
- * @example
100
- * ``` typescript
101
- * Mx.MxFun.setMxServer("ws://localhost:5090")
102
- * ```
103
- */
104
- MxFun.prototype.setMxServer = function (MXSERVER) {
105
- if (MXSERVER === void 0) { MXSERVER = 'ws://localhost:5090'; }
106
- ;
107
- store_1.default.state.MxFun.setMxServer(MXSERVER);
108
- };
109
- /**
110
- * 设置加载dwg文件,直接使用html get协议加载数据,这样就不需要梦想后台服务器程序。
111
- * @param isStaticLoad 是否启用html get协议加载数据文件
112
- * @return void
113
- * @example
114
- * ``` typescript
115
- * Mx.MxFun.enablStaticLoad(true)
116
- * ```
117
- */
118
- MxFun.prototype.enablStaticLoad = function (isStaticLoad) {
119
- ;
120
- store_1.default.state.MxFun.enablStaticLoad(isStaticLoad);
121
- };
122
- /**
123
- * 设置加载dwg文件,直接使用html get协议加载数据时,使用的服务器地址。
124
- * @param server 服务网络地址.
125
- * @return void
126
- * @example
127
- * ``` typescript
128
- * Mx.MxFun.setStaticServer("http://localhost:3000/demo");
129
- * ```
130
- */
131
- MxFun.prototype.setStaticServer = function (server) {
132
- ;
133
- store_1.default.state.MxFun.setStaticServer(server);
134
- };
135
- /**
136
- * 注册命令
137
- * @param cmdName 命令名
138
- * @param fun 命令函数
139
- * @return void
140
- * @example
141
- * ``` typescript
142
- * Mx.MxFun.addCommand("draw", ()=> {
143
- * console.log("draw")
144
- * })
145
- * ```
146
- */
147
- MxFun.prototype.addCommand = function (cmdName, fun) {
148
- ;
149
- store_1.default.state.MxFun.addCommand(cmdName, fun);
150
- };
151
- /**
152
- * 执行命令
153
- * @param cmdName 命令名
154
- * @return boolean 命令执行成功为true
155
- * @example
156
- * ``` typescript
157
- * if(Mx.MxFun.sendStringToExecute("draw")) {
158
- * console.log("成功执行draw命令")
159
- * }
160
- * ```
161
- */
162
- MxFun.prototype.sendStringToExecute = function (cmdName) {
163
- var _a;
164
- var ages = [];
165
- for (var _i = 1; _i < arguments.length; _i++) {
166
- ages[_i - 1] = arguments[_i];
167
- }
168
- return (_a = store_1.default.state.MxFun).sendStringToExecute.apply(_a, __spreadArray([cmdName], ages, false));
169
- };
170
- /**
171
- * 调用后台服务程序中的NodeJS用户定义函数 后台程序使用Mx.MxFun.registFun注册用户定义函数
172
- * @param funName 函数名
173
- * @param param 函数参数
174
- * @param retfun 函数返回值回调
175
- * @return void
176
- * @example
177
- * ``` typescript
178
- * Mx.MxFun.call("getDrawObject", {
179
- * cadFile: "test.dwg"
180
- * }, (res)=> {
181
- * console.log(res)
182
- * })
183
- * ```
184
- */
185
- MxFun.prototype.call = function (funName, param, retfun) {
186
- return store_1.default.state.MxFun.call(funName, param, retfun);
187
- };
188
- /**
189
- * 获取当前绘图控件对象
190
- * @return MxDrawObjectType 当前绘图控件对象
191
- * @example
192
- * ``` typescript
193
- * const mxDraw = Mx.MxFun.getCurrentDraw()
194
- * mxDraw.getScene()
195
- * ```
196
- */
197
- MxFun.prototype.getCurrentDraw = function () {
198
- return new MxDrawObject_1.default(store_1.default.state.MxFun.getCurrentDraw());
199
- };
200
- /**
201
- * 屏幕坐标长度转THREE.JS坐标长度
202
- * @param len 屏幕坐标长度
203
- * @return number THREE.JS坐标长度
204
- * @example
205
- * ``` typescript
206
- * const len = Mx.MxFun.screenCoordLong2World(36)
207
- * console.log(len)
208
- * ```
209
- */
210
- MxFun.prototype.screenCoordLong2World = function (len) {
211
- return store_1.default.state.MxFun.screenCoordLong2World(len);
212
- };
213
- /**
214
- * 屏幕坐标长度转文档坐标长度
215
- * @param len 屏幕坐标长度
216
- * @return number 文档坐标长度
217
- * @example
218
- * ``` typescript
219
- * const len = Mx.MxFun.screenCoordLong2Doc(36)
220
- * console.log(len)
221
- * ```
222
- */
223
- MxFun.prototype.screenCoordLong2Doc = function (len) {
224
- return store_1.default.state.MxFun.screenCoordLong2Doc(len);
225
- };
226
- /**
227
- * 文档坐标长度转屏幕坐标长度
228
- * @param len 文档坐标长度
229
- * @return number 屏幕坐标长度
230
- * @example
231
- * ``` typescript
232
- * const len = Mx.MxFun.docCoordLong2Screen(36)
233
- * console.log(len)
234
- * ```
235
- */
236
- MxFun.prototype.docCoordLong2Screen = function (len) {
237
- return store_1.default.state.MxFun.docCoordLong2Screen(len);
238
- };
239
- /**
240
- * THREE.JS坐标长度转屏幕坐标长度
241
- * @param len THREE.JS坐标长度
242
- * @return number 屏幕坐标长度
243
- * @example
244
- * ``` typescript
245
- * const len = Mx.MxFun.worldCoordLong2Doc(36)
246
- * console.log(len)
247
- * ```
248
- */
249
- MxFun.prototype.worldCoordLong2Doc = function (len) {
250
- return store_1.default.state.MxFun.worldCoordLong2Doc(len);
251
- };
252
- /**
253
- * DWG文档坐标长度到ThreeJS坐标长度
254
- * @returns number
255
- * @example
256
- * ```typescript
257
- *
258
- *
259
- * ```
260
- */
261
- MxFun.prototype.docCoordLong2World = function (l) {
262
- return store_1.default.state.MxFun.docCoordLong2World(l);
263
- };
264
- /**
265
- * 屏幕坐标转THREE.JS坐标.
266
- * @param x 坐标x
267
- * @param y 坐标y
268
- * @param z 坐标z
269
- * @return THREE.Vector3 THREE.JS坐标
270
- * @example
271
- * ``` typescript
272
- * const vector3 = Mx.MxFun.screenCoord2World(36, 21, 0)
273
- * console.log(vector3)
274
- * ```
275
- */
276
- MxFun.prototype.screenCoord2World = function (x, y, z) {
277
- return store_1.default.state.MxFun.screenCoord2World(x, y, z);
278
- };
279
- /**
280
- * THREE.JS坐标转屏幕坐标.,屏幕坐标的Y轴向下。坐标原点在左上角.
281
- * @param x 坐标x
282
- * @param y 坐标y
283
- * @param z 坐标z
284
- * @return THREE.Vector3 屏幕坐标
285
- * @example
286
- * ``` typescript
287
- * const vector3 = Mx.MxFun.worldCoord2Screen(36, 21, 0)
288
- * console.log(vector3)
289
- * ```
290
- */
291
- MxFun.prototype.worldCoord2Screen = function (x, y, z) {
292
- return store_1.default.state.MxFun.worldCoord2Screen(x, y, z);
293
- };
294
- /**
295
- * 文档坐标转THREE.JS坐标
296
- * 说明: 文档坐标,THREE.JS坐标的X轴都是从左到右,Y轴是下到上,但是屏幕像素坐标系:X轴都是从左到右,Y轴是上到下
297
- * @param x 坐标x
298
- * @param y 坐标y
299
- * @param z 坐标z
300
- * @return THREE.Vector3 THREE.JS坐标
301
- * @example
302
- * ``` typescript
303
- * const vector3 = Mx.MxFun.docCoord2World(36, 21, 0)
304
- * console.log(vector3)
305
- * ```
306
- */
307
- MxFun.prototype.docCoord2World = function (x, y, z) {
308
- return store_1.default.state.MxFun.docCoord2World(x, y, z);
309
- };
310
- /**
311
- * THREE.JS坐标转文档坐标.
312
- * @param x 坐标x
313
- * @param y 坐标y
314
- * @param z 坐标z
315
- * @return THREE.Vector3 文档坐标
316
- * @example
317
- * ``` typescript
318
- * const vector3 = Mx.MxFun.worldCoord2Doc(36, 21, 0)
319
- * console.log(vector3)
320
- * ```
321
- */
322
- MxFun.prototype.worldCoord2Doc = function (x, y, z) {
323
- return store_1.default.state.MxFun.worldCoord2Doc(x, y, z);
324
- };
325
- /**
326
- * 屏幕转文档坐标
327
- * @param x 坐标x
328
- * @param y 坐标y
329
- * @param z 坐标z
330
- * @return THREE.Vector3 文档坐标
331
- * @example
332
- * ``` typescript
333
- * const vector3 = Mx.MxFun.screenCoord2Doc(36, 21, 0)
334
- * console.log(vector3)
335
- * ```
336
- */
337
- MxFun.prototype.screenCoord2Doc = function (x, y) {
338
- return store_1.default.state.MxFun.screenCoord2Doc(x, y, 0);
339
- };
340
- /**
341
- * 文档转屏幕坐标.
342
- * @param x 坐标x
343
- * @param y 坐标y
344
- * @param z 坐标z
345
- * @return THREE.Vector3 屏幕坐标
346
- * @example
347
- * ``` typescript
348
- * const vector3 = Mx.MxFun.docCoord2Screen(36, 21, 0)
349
- * console.log(vector3)
350
- * ```
351
- */
352
- MxFun.prototype.docCoord2Screen = function (x, y) {
353
- return store_1.default.state.MxFun.docCoord2Screen(x, y, 0);
354
- };
355
- /**
356
- * 更新显示,使用Three.js绘制了对象,调用该函数更新显示。
357
- * @return void
358
- * @example
359
- * ``` typescript
360
- * Mx.MxFun.updateDisplay()
361
- * ```
362
- */
363
- MxFun.prototype.updateDisplay = function () {
364
- return store_1.default.state.MxFun.updateDisplay();
365
- };
366
- /**
367
- * 设置窗口鼠标等事件的回调操作
368
- * @param fun 参数1 type: 鼠标事件类型 "mouseup"鼠标释放 、"mousedown" 鼠标按下 参数2 event:事件对象 返回值: number 为0,表示事件往下传递,如果非0,表示事件已经被处理,不要往下传递了
369
- * @return void
370
- * @example
371
- * ``` typescript
372
- * Mx.MxFun.addWindowsEvent((type, event)=> {
373
- * console.log(event)
374
- * if(type = "mouseup") {
375
- * console.log("鼠标释放")
376
- * }else {
377
- * console.log("鼠标按下")
378
- * }
379
- * // 事件往下传递
380
- * // return 0
381
- * // 事件已处理不再传递
382
- * return -1
383
- * })
384
- * ```
385
- */
386
- MxFun.prototype.addWindowsEvent = function (fun) {
387
- return store_1.default.state.MxFun.addWindowsEvent(fun);
388
- };
389
- /**
390
- * 当前是否有命令在运行
391
- * @return boolean
392
- * @example
393
- * ``` typescript
394
- * if(Mx.MxFun.isRunningCommand()) {
395
- * // 当前已有命令在运行
396
- * }
397
- * ```
398
- */
399
- MxFun.prototype.isRunningCommand = function () {
400
- return store_1.default.state.MxFun.isRunningCommand();
401
- };
402
- /**
403
- * 窗口缩放,把指定的范围内的图形放到视区中
404
- * @param dLBx 矩形框范围的左下角X坐标
405
- * @param dLBy 矩形框范围的左下角X坐标
406
- * @param dRTx 矩形框范围的左下角X坐标
407
- * @param dRTy 矩形框范围的左下角X坐标
408
- * @param isWorld 传入的坐标是否是thruee.js坐标,默认传文档坐标
409
- * @return void
410
- * @example
411
- * ``` typescript
412
- * Mx.MxFun.zoomW(21, 22, 300, 310, false)
413
- * ```
414
- */
415
- MxFun.prototype.zoomW = function (dLBx, dLBy, dRTx, dRTy, isWorld) {
416
- return store_1.default.state.MxFun.zoomW(dLBx, dLBy, dRTx, dRTy, isWorld);
417
- };
418
- /**
419
- * 显示或隐藏图层
420
- * @param idLayer 图层id,或层名
421
- * @param isShow 是否显示
422
- * @param isSketch 暂不使用
423
- * @return void
424
- * @example
425
- * ``` typescript
426
- * Mx.MxFun.showLayer(366, true, false)
427
- * Mx.MxFun.showLayer("2363", fasle, false)
428
- * ```
429
- */
430
- MxFun.prototype.showLayer = function (idLayer, isShow, isSketch) {
431
- return store_1.default.state.MxFun.showLayer(idLayer, isShow, isSketch);
432
- };
433
- // acutPrintf(sval: string, ...val: string[]): void {
434
- // (store.state.MxFun as MxFunType).acutPrintf(sval, ...val)
435
- // }
436
- /**
437
- * 获取当前MxCAD对象,该函数在MxCAD模式下使用
438
- * @return MxDrawObjectType MxCAD对象
439
- * @example
440
- * ``` typescript
441
- * const mxcad = Mx.MxFun.getCurrentMxCAD()
442
- * console.log(mxcad)
443
- * ```
444
- */
445
- MxFun.prototype.getCurrentMxCAD = function () {
446
- // 暂时还没有实现。
447
- return store_1.default.state.MxFun.getCurrentMxCAD();
448
- };
449
- /**
450
- * 得到地址栏参数
451
- * @param name
452
- * @return string 地址栏参数
453
- * @example
454
- * ``` typescript
455
- * if(Mx.MxFun.getQueryString("mousetest") === "y")
456
- * ```
457
- */
458
- MxFun.prototype.getQueryString = function (name) {
459
- return store_1.default.state.MxFun.getQueryString(name);
460
- };
461
- /**
462
- * 设置控件的配制参数.
463
- * @param name
464
- * @return object 配制参数.
465
- * @example
466
- * ``` typescript
467
- * Mx.MxFun.setIniset({
468
- * EnableIntelliSelect: true
469
- * })
470
- * ```
471
- */
472
- MxFun.prototype.setIniset = function (iniObj) {
473
- return store_1.default.state.MxFun.setIniset(iniObj);
474
- };
475
- /**
476
- * 更新图纸图层数据
477
- * @param dataLayers
478
- * @return boolean 更新成功或失败
479
- * @example
480
- * ``` typescript
481
- * if(Mx.MxFun.upDisplayForLayerData({
482
- *
483
- * })) {
484
- * console.log("更新成功")
485
- * }
486
- * ```
487
- */
488
- MxFun.prototype.upDisplayForLayerData = function (dataLayers) {
489
- return store_1.default.state.MxFun.upDisplayForLayerData(dataLayers);
490
- };
491
- /**
492
- * 初始化插件的UI数据对象。
493
- * @param uiDataObj
494
- * @return
495
- * @example
496
- * ``` typescript
497
- * ```
498
- */
499
- MxFun.prototype.initUiDataObject = function (uiDataObj) {
500
- return store_1.default.state.MxFun.initUiDataObject(uiDataObj);
501
- };
502
- /**
503
- * 梦想开发测试
504
- * @param p
505
- * @return any
506
- * @example
507
- * ``` typescript
508
- * console.log(Mx.MxFun.TestMX());
509
- * ```
510
- */
511
- MxFun.prototype.testMX = function (p) {
512
- return 5 + 6;
513
- };
514
- /**
515
- * 加载一个图片对象,返回Three.js材质对象,该函数具有缓存功能,下次加载同样的图片,可以直接返回.
516
- * @param p
517
- * @return any
518
- * @example
519
- * ``` typescript
520
- *
521
- * ```
522
- */
523
- MxFun.prototype.loadImageMaterial = function (imageUrlPath, callResult) {
524
- if (callResult) {
525
- ;
526
- store_1.default.state.MxFun.loadImageMaterial(imageUrlPath, callResult);
527
- return new Promise(function (resolve, reject) {
528
- resolve(null);
529
- });
530
- }
531
- else {
532
- return new Promise(function (resolve, reject) {
533
- ;
534
- store_1.default.state.MxFun.loadImageMaterial(imageUrlPath, function (material) {
535
- if (material) {
536
- resolve(material);
537
- }
538
- else {
539
- resolve(null);
540
- }
541
- });
542
- });
543
- }
544
- };
545
- /**
546
- * 判断点是否在一个闭合的多边形区域。
547
- * @param p
548
- * @return any
549
- * @example
550
- * ``` typescript
551
- * let aryPoint:Array<THREE.Vector3> = [];
552
- * aryPoint.push(new THREE.Vector3(0,0,0));
553
- * aryPoint.push(new THREE.Vector3(0,100,0));
554
- * aryPoint.push(new THREE.Vector3(100,100,0));
555
- * aryPoint.push(new THREE.Vector3(100,0,0));
556
- * let pt:THREE.Vector3 = new THREE.Vector3(150,150);
557
- * if(MxFun.pointInPolyline(pt,aryPoint) ){
558
- * console.log("in");
559
- * }
560
- * ```
561
- */
562
- MxFun.prototype.pointInPolyline = function (pt, vecPolyline) {
563
- return store_1.default.state.MxFun.pointInPolyline(pt, vecPolyline);
564
- };
565
- /**
566
- * 计算多边形区域的面积
567
- * @param p
568
- * @return any
569
- * @example
570
- * ``` typescript
571
- * ```
572
- */
573
- MxFun.prototype.calcArea = function (aryPoint) {
574
- return store_1.default.state.MxFun.calcArea(aryPoint);
575
- };
576
- /**
577
- * 重新打开cad文件,该函数在控件创建完后,需要再次重新打开文件,调用。
578
- * @param sFile 打的cad文件路径
579
- * @return any
580
- * @example
581
- * ``` typescript
582
- * ```
583
- */
584
- MxFun.prototype.openFile = function (sFile, useWebsocket) {
585
- if (useWebsocket === void 0) { useWebsocket = false; }
586
- return store_1.default.state.MxFun.openFile(sFile, useWebsocket);
587
- };
588
- /**
589
- * 添加一个MxDbEntity实体到当前绘图对象上。
590
- * @param ent 实体对象
591
- * @returns number 返回对象的id.
592
- * @example
593
- * ```typescript
594
- *
595
- *
596
- * ```
597
- */
598
- MxFun.prototype.addToCurrentSpace = function (ent) {
599
- return this.getCurrentDraw().addMxEntity(ent);
600
- };
601
- /**
602
- * 在图上选择一个对象。
603
- * @param strPrompt 提示字符串
604
- * @param filter 过滤条件
605
- * @returns number 返回对象的id
606
- * @example
607
- * ```typescript
608
- *
609
- *
610
- * ```
611
- */
612
- MxFun.prototype.selectEnt = function (strPrompt, filter) {
613
- var _this = this;
614
- if (filter === void 0) { filter = null; }
615
- return new Promise(function (resolve, reject) {
616
- var getPoint = new MrxDbgUiPrPoint_1.default();
617
- getPoint.setMessage(strPrompt);
618
- getPoint.go(function (status) {
619
- if (status != 0) {
620
- resolve(0);
621
- return;
622
- }
623
- var pt = getPoint.value();
624
- var mxobj = _this.getCurrentDraw();
625
- var aryFind = mxobj.findMxEntityAtPoint(pt);
626
- var iFindId = 0;
627
- while (true) {
628
- if (aryFind.length == 0) {
629
- break;
630
- }
631
- var iLen = aryFind.length;
632
- for (var i = 0; i < iLen; i++) {
633
- var ent = aryFind[i];
634
- if (filter) {
635
- if (filter['type'] && filter['type'] != ent.getTypeName()) {
636
- continue;
637
- }
638
- }
639
- iFindId = ent.objectId();
640
- break;
641
- }
642
- break;
643
- }
644
- resolve(iFindId);
645
- });
646
- });
647
- };
648
- /**
649
- * 监听命令行消息动态更新的数据
650
- * 在取点对象中设置的命令以及我们提供的图形对象中是有一套命令提示和参数化绘图,而该回调函数主要用来监听消息变化
651
- * @parma callback 回调函数中data中的msCmdTip表示命令提示 msCmdText表示当前用户输入的输入内容 msCmdDisplay表示所有的消息记录
652
- * */
653
- MxFun.prototype.listenForCommandLineInput = function (callback) {
654
- var cmdLine = mxUiData_1.default.getCmdLine();
655
- cmdLine.mountUpDisplayFun(callback);
656
- };
657
- /**
658
- * 设置命令行消息数据 (在监听input输入框的onKeydown事件的回调函数中调用)
659
- * @param msCmdText 用户输入的数据 input输入框输入的文本信息
660
- * @param keyCode 按键Code input输入框的onKeydown事件的event事件对象的keyCode属性
661
- * */
662
- MxFun.prototype.setCommandLineInputData = function (msCmdText, keyCode) {
663
- var cmdLine = mxUiData_1.default.getCmdLine();
664
- cmdLine.setCmdText(msCmdText);
665
- mxUiData_1.default.onKeydown(keyCode);
666
- };
667
- /**
668
- * 监听指针(鼠标光标)移动变化的坐标信息
669
- * @parma callback 回调函数中返回坐标信息
670
- * */
671
- MxFun.prototype.listenForCoordTip = function (callback) {
672
- mxUiData_1.default.mountSetCoordFun(callback);
673
- };
674
- return MxFun;
675
- }());
676
- exports.default = MxFun;
1
+ "use strict";var __spreadArray=this&&this.__spreadArray||function(t,e,o){if(o||2===arguments.length)for(var r,n=0,a=e.length;n<a;n++)!r&&n in e||(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(exports,"__esModule",{value:!0});var random_1=require("../../tools/algorithm/random"),create_1=require("../../tools/dom/create"),MxDrawObject_1=require("../MxDrawObject"),store_1=require("../store"),useCanvasResizeListener_1=require("../useCanvasResizeListener"),MrxDbgUiPrPoint_1=require("../MrxDbgUiPrPoint"),mxUiData_1=require("../loadCoreCode/mxUiData"),MxFun=function(){function t(){}return t.prototype.createMxObject=function(t){var e=t.canvasId,o=void 0===e?(0,random_1.createReandomId)():e,r=t.cadFile,n=void 0===r?"":r,a=t.callback,u=t.isNewFile,i=void 0!==u&&u,d=t.useWebsocket,s=void 0!==d&&d,c=t.isAutoResize,l=void 0===c||c;this.initUiDataObject(mxUiData_1.default);var p=(0,create_1.createCanvas)(o),f=(0,create_1.createCanvasParent)(p);f.parentNode&&11!=f.parentNode.nodeType||document.body.appendChild(f),!s&&i&&(i=!1),store_1.default.state.MxFun.createMxObject(o,n,function(t){var e=new MxDrawObject_1.default(t);t.setMouseRightRotate(!1),t.setIniset({EnableOsnapFunction:!0}),t.addEvent("onResize",function(){return f.tabindex=3,{width:f.clientWidth,height:f.clientHeight}}),l&&(0,useCanvasResizeListener_1.default)(e,p),a&&a(e,{canvas:p,canvasParent:f})},void 0,i,s)},t.prototype.setMxServer=function(t){void 0===t&&(t="ws://localhost:5090"),store_1.default.state.MxFun.setMxServer(t)},t.prototype.enablStaticLoad=function(t){store_1.default.state.MxFun.enablStaticLoad(t)},t.prototype.setStaticServer=function(t){store_1.default.state.MxFun.setStaticServer(t)},t.prototype.addCommand=function(t,e){store_1.default.state.MxFun.addCommand(t,e)},t.prototype.sendStringToExecute=function(t){for(var e,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return(e=store_1.default.state.MxFun).sendStringToExecute.apply(e,__spreadArray([t],o,!1))},t.prototype.call=function(t,e,o){return store_1.default.state.MxFun.call(t,e,o)},t.prototype.getCurrentDraw=function(){return new MxDrawObject_1.default(store_1.default.state.MxFun.getCurrentDraw())},t.prototype.screenCoordLong2World=function(t){return store_1.default.state.MxFun.screenCoordLong2World(t)},t.prototype.screenCoordLong2Doc=function(t){return store_1.default.state.MxFun.screenCoordLong2Doc(t)},t.prototype.docCoordLong2Screen=function(t){return store_1.default.state.MxFun.docCoordLong2Screen(t)},t.prototype.worldCoordLong2Doc=function(t){return store_1.default.state.MxFun.worldCoordLong2Doc(t)},t.prototype.docCoordLong2World=function(t){return store_1.default.state.MxFun.docCoordLong2World(t)},t.prototype.screenCoord2World=function(t,e,o){return store_1.default.state.MxFun.screenCoord2World(t,e,o)},t.prototype.worldCoord2Screen=function(t,e,o){return store_1.default.state.MxFun.worldCoord2Screen(t,e,o)},t.prototype.docCoord2World=function(t,e,o){return store_1.default.state.MxFun.docCoord2World(t,e,o)},t.prototype.worldCoord2Doc=function(t,e,o){return store_1.default.state.MxFun.worldCoord2Doc(t,e,o)},t.prototype.screenCoord2Doc=function(t,e){return store_1.default.state.MxFun.screenCoord2Doc(t,e,0)},t.prototype.docCoord2Screen=function(t,e){return store_1.default.state.MxFun.docCoord2Screen(t,e,0)},t.prototype.updateDisplay=function(){return store_1.default.state.MxFun.updateDisplay()},t.prototype.addWindowsEvent=function(t){return store_1.default.state.MxFun.addWindowsEvent(t)},t.prototype.isRunningCommand=function(){return store_1.default.state.MxFun.isRunningCommand()},t.prototype.zoomW=function(t,e,o,r,n){return store_1.default.state.MxFun.zoomW(t,e,o,r,n)},t.prototype.showLayer=function(t,e,o){return store_1.default.state.MxFun.showLayer(t,e,o)},t.prototype.getCurrentMxCAD=function(){return store_1.default.state.MxFun.getCurrentMxCAD()},t.prototype.getQueryString=function(t){return store_1.default.state.MxFun.getQueryString(t)},t.prototype.setIniset=function(t){return store_1.default.state.MxFun.setIniset(t)},t.prototype.upDisplayForLayerData=function(t){return store_1.default.state.MxFun.upDisplayForLayerData(t)},t.prototype.initUiDataObject=function(t){return store_1.default.state.MxFun.initUiDataObject(t)},t.prototype.testMX=function(t){return 11},t.prototype.loadImageMaterial=function(t,e){return e?(store_1.default.state.MxFun.loadImageMaterial(t,e),new Promise(function(t,e){t(null)})):new Promise(function(e,o){store_1.default.state.MxFun.loadImageMaterial(t,function(t){e(t||null)})})},t.prototype.openFile=function(t,e){return void 0===e&&(e=!1),store_1.default.state.MxFun.openFile(t,e)},t.prototype.addToCurrentSpace=function(t){return this.getCurrentDraw().addMxEntity(t)},t.prototype.selectEnt=function(t,e){var o=this;return void 0===e&&(e=null),new Promise(function(r,n){var a=new MrxDbgUiPrPoint_1.default;a.setMessage(t),a.go(function(t){if(0==t){for(var n=a.value(),u=o.getCurrentDraw().findMxEntityAtPoint(n),i=0;0!=u.length;){for(var d=u.length,s=0;s<d;s++){var c=u[s];if(!e||!e.type||e.type==c.getTypeName()){i=c.objectId();break}}break}r(i)}else r(0)})})},t.prototype.listenForCommandLineInput=function(t){mxUiData_1.default.getCmdLine().mountUpDisplayFun(t)},t.prototype.setCommandLineInputData=function(t,e){mxUiData_1.default.getCmdLine().setCmdText(t),mxUiData_1.default.onKeydown(e)},t.prototype.listenForCoordTip=function(t){mxUiData_1.default.mountSetCoordFun(t)},t.prototype.getMxFunTHREE=function(){return store_1.default.state.MxFun.getTHREE()},t.prototype.getMxFunThreeTool=function(){return store_1.default.state.MxFun.getMxThreeJS()},t}();exports.default=MxFun;
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var MxFun_1 = require("./MxFun");
4
- exports.default = new MxFun_1.default();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var MxFun_1=require("./MxFun");exports.default=new MxFun_1.default;